diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2021-02-06 07:21:13 -0500 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2021-02-06 07:38:49 -0500 |
commit | 2e4b2977c78e254797d07c39e933fd535d4b0cec (patch) | |
tree | 568340a9837fabafee6a818db905d8ec15112d8d /tests/helpers.py | |
parent | b7160a896252bb92ffe921a37e3cde98c5cb78b9 (diff) | |
download | python-coveragepy-git-2e4b2977c78e254797d07c39e933fd535d4b0cec.tar.gz |
refactor: remove unittest.assertCountEqual
Another step toward removing unittest.TestCase.
Diffstat (limited to 'tests/helpers.py')
-rw-r--r-- | tests/helpers.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/helpers.py b/tests/helpers.py index 0621d7a9..1348aad6 100644 --- a/tests/helpers.py +++ b/tests/helpers.py @@ -3,6 +3,7 @@ """Helpers for coverage.py tests.""" +import collections import glob import os import re @@ -222,3 +223,13 @@ def without_module(using_module, missing_module_name): """ return mock.patch.object(using_module, missing_module_name, None) + + +def assert_count_equal(a, b): + """ + A pytest-friendly implementation of assertCountEqual. + + Assert that `a` and `b` have the same elements, but maybe in different order. + This only works for hashable elements. + """ + assert collections.Counter(list(a)) == collections.Counter(list(b)) |