Skip to content

Commit

Permalink
Merge pull request #14 from pomponchik/develop
Browse files Browse the repository at this point in the history
0.0.12
  • Loading branch information
pomponchik authored Feb 3, 2024
2 parents 7988ada + c158074 commit 2dee6f1
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 2 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,7 @@ dist
build
.ruff_cache
.mypy_cache
.mutmut-cache
html
.coverage
htmlcov
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
[![Downloads](https://static.pepy.tech/badge/locklib/month)](https://pepy.tech/project/locklib)
[![Downloads](https://static.pepy.tech/badge/locklib)](https://pepy.tech/project/locklib)
[![codecov](https://codecov.io/gh/pomponchik/locklib/graph/badge.svg?token=O9G4FD8QFC)](https://codecov.io/gh/pomponchik/locklib)
[![Lines of code](https://sloc.xyz/github/pomponchik/locklib/?category=code)](https://github.com/boyter/scc/)
[![Hits-of-Code](https://hitsofcode.com/github/pomponchik/locklib?branch=main)](https://hitsofcode.com/github/pomponchik/locklib/view?branch=main)
[![Test-Package](https://github.com/pomponchik/locklib/actions/workflows/tests_and_coverage.yml/badge.svg)](https://github.com/pomponchik/locklib/actions/workflows/tests_and_coverage.yml)
[![Python versions](https://img.shields.io/pypi/pyversions/locklib.svg)](https://pypi.python.org/pypi/locklib)
Expand Down
6 changes: 5 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = 'setuptools.build_meta'

[project]
name = 'locklib'
version = '0.0.11'
version = '0.0.12'
authors = [
{ name='Evgeniy Blinov', email='[email protected]' },
]
Expand All @@ -30,6 +30,10 @@ classifiers = [
[tool.setuptools.package-data]
"locklib" = ["py.typed"]

[tool.mutmut]
paths_to_mutate="locklib"
runner="pytest"

[project.urls]
'Source' = 'https://github.com/pomponchik/locklib'
'Tracker' = 'https://github.com/pomponchik/locklib/issues'
1 change: 1 addition & 0 deletions requirements_dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ wheel==0.41.2
build==0.9.0
ruff==0.0.290
mypy==1.4.1
mutmut==2.4.4
30 changes: 30 additions & 0 deletions tests/life_lock/test_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,24 @@ def test_set_get_delete_and_get():
assert graph.get_links_from(1) == {3, 4}


def test_delete_from_empty_graph():
graph = LocksGraph()

graph.delete_link(1, 2)

assert not graph.links


def test_delete_non_existing_link():
graph = LocksGraph()

graph.add_link(1, 2)

graph.delete_link(1, 3)

assert graph.get_links_from(1) == {2,}


def test_detect_simple_cycle():
graph = LocksGraph()

Expand Down Expand Up @@ -91,3 +109,15 @@ def test_exception_message_not_so_simple():
graph.add_link(4, 1)

assert str(e.value) == 'A cycle between 4th and 1th threads has been detected. The full path of the cycle: 4, 3, 2, 1.'


def test_exception_message_not_so_simple_2():
graph = LocksGraph()

graph.add_link(1, 2)
graph.add_link(2, 3)

with pytest.raises(DeadLockError) as e:
graph.add_link(3, 1)

assert str(e.value) == 'A cycle between 3th and 1th threads has been detected. The full path of the cycle: 3, 2, 1.'
7 changes: 6 additions & 1 deletion tests/life_lock/test_lock.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import re
from time import sleep
from queue import Queue
from threading import Thread, Lock
Expand All @@ -7,10 +8,14 @@
from locklib import SmartLock, DeadLockError


def full_match_regex(string_to_match: str) -> str:
return '^' + re.escape(string_to_match) + '$'


def test_release_unlocked():
lock = SmartLock()

with pytest.raises(RuntimeError):
with pytest.raises(RuntimeError, match=full_match_regex('Release unlocked lock.')):
lock.release()


Expand Down

0 comments on commit 2dee6f1

Please sign in to comment.