From 12cba4a50b7bdc211e6800cb385176a81761712c Mon Sep 17 00:00:00 2001 From: Yusuke Kadowaki Date: Wed, 30 Nov 2022 23:12:52 +0900 Subject: [PATCH] Refactor test --- testing/test_tmpdir.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/testing/test_tmpdir.py b/testing/test_tmpdir.py index 38048731e..c315055f9 100644 --- a/testing/test_tmpdir.py +++ b/testing/test_tmpdir.py @@ -117,9 +117,9 @@ class TestConfigTmpPath: root = pytester._test_tmproot for child in root.iterdir(): - base_dir = filter(lambda x: x.is_dir(), child.iterdir()) + base_dir = list(child.iterdir()) # Check the base dir itself is gone without depending on test results - assert len(list(base_dir)) == 0 + assert base_dir == [] @pytest.mark.parametrize("policy", ["failed", "all"]) @pytest.mark.parametrize("count", [0, 1, 3]) @@ -157,7 +157,6 @@ class TestConfigTmpPath: root = pytester._test_tmproot for child in root.iterdir(): base_dir = filter(lambda x: not x.is_symlink(), child.iterdir()) - # Check the base dir itself is gone assert len(list(base_dir)) == count def test_policy_failed_removes_only_passed_dir(self, pytester: Pytester) -> None: @@ -200,9 +199,9 @@ class TestConfigTmpPath: pytester.inline_run(p) root = pytester._test_tmproot for child in root.iterdir(): - base_dir = filter(lambda x: x.is_dir(), child.iterdir()) + base_dir = list(child.iterdir()) # Check the base dir itself is gone - assert len(list(base_dir)) == 0 + assert base_dir == [] # issue #10502 def test_policy_failed_removes_dir_when_skipped_from_fixture( @@ -225,10 +224,8 @@ class TestConfigTmpPath: # Check if the whole directory is removed root = pytester._test_tmproot for child in root.iterdir(): - base_dir = list( - filter(lambda x: x.is_dir() and not x.is_symlink(), child.iterdir()) - ) - assert len(base_dir) == 0 + base_dir = list(child.iterdir()) + assert base_dir == [] # issue #10502 def test_policy_all_keeps_dir_when_skipped_from_fixture(