diff --git a/setup.py b/setup.py index a7e9c232..5a60d6be 100644 --- a/setup.py +++ b/setup.py @@ -36,8 +36,9 @@ "coverage[toml]", "freezegun>=0.2.8", "pretend", - "pytest>=3.3.0", "pytest-asyncio; python_version>='3.7'", + "pytest-randomly", + "pytest>=3.3.0", "python-rapidjson", "simplejson", ], diff --git a/tests/test_stdlib.py b/tests/test_stdlib.py index 89d9b534..bcaef7b8 100644 --- a/tests/test_stdlib.py +++ b/tests/test_stdlib.py @@ -118,8 +118,9 @@ def test_find_caller(self, monkeypatch): assert log_record.filename == os.path.basename(__file__) def test_sets_correct_logger(self): - assert logging.getLoggerClass() is logging.Logger - + """ + Calling LoggerFactory ensures that Logger.findCaller gets patched. + """ LoggerFactory() assert logging.getLoggerClass() is _FixedFindCallerLogger diff --git a/tests/test_threadlocal.py b/tests/test_threadlocal.py index 685a7bba..6a70330f 100644 --- a/tests/test_threadlocal.py +++ b/tests/test_threadlocal.py @@ -284,6 +284,7 @@ def test_bind_and_merge(self): Binding a variable causes it to be included in the result of merge_threadlocal. """ + clear_threadlocal() bind_threadlocal(a=1) assert {"a": 1, "b": 2} == merge_threadlocal(None, None, {"b": 2}) @@ -303,6 +304,8 @@ def test_merge_works_without_bind(self): merge_threadlocal returns values as normal even when there has been no previous calls to bind_threadlocal. """ + clear_threadlocal() + assert {"b": 2} == merge_threadlocal(None, None, {"b": 2}) def test_multiple_binds(self): @@ -310,6 +313,7 @@ def test_multiple_binds(self): Multiple calls to bind_threadlocal accumulate values instead of replacing them. """ + clear_threadlocal() bind_threadlocal(a=1, b=2) bind_threadlocal(c=3) @@ -325,6 +329,7 @@ def test_unbind_threadlocal(self): clear_threadlocal() bind_threadlocal(a=234, b=34) + assert {"a": 234, "b": 34} == merge_threadlocal_context(None, None, {}) unbind_threadlocal("a")