Skip to content

Commit

Permalink
Ensure tests pass in any order.
Browse files Browse the repository at this point in the history
  • Loading branch information
hynek committed Mar 7, 2020
1 parent 9d2544a commit a5768fa
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
],
Expand Down
5 changes: 3 additions & 2 deletions tests/test_stdlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions tests/test_threadlocal.py
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand All @@ -303,13 +304,16 @@ 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):
"""
Multiple calls to bind_threadlocal accumulate values instead of
replacing them.
"""
clear_threadlocal()
bind_threadlocal(a=1, b=2)
bind_threadlocal(c=3)

Expand All @@ -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")
Expand Down

0 comments on commit a5768fa

Please sign in to comment.