Skip to content

Commit

Permalink
make test more reliable on win
Browse files Browse the repository at this point in the history
  • Loading branch information
giampaolo committed Oct 6, 2024
1 parent 6fe9be9 commit 838107e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
1 change: 1 addition & 0 deletions psutil/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -939,6 +939,7 @@ def main(*args, **kw): # noqa ARG004
UserWarning,
stacklevel=1,
)
return suite

@staticmethod
def raises(exc, match=None):
Expand Down
14 changes: 6 additions & 8 deletions psutil/tests/test_testutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -486,20 +486,18 @@ def test_main(self):
pass
with open(os.path.join(tmpdir, "test_file.py"), "w") as f:
f.write(textwrap.dedent("""\
import unittest, os
import unittest
class TestCase(unittest.TestCase):
def test_foo(self):
path = os.path.join("{}", "hello.txt")
with open(path, "w") as f:
pass
""".format(tmpdir)).lstrip())
def test_passed(self):
pass
""").lstrip())
with mock.patch.object(psutil.tests, "HERE", tmpdir):
with self.assertWarnsRegex(
UserWarning, "Fake pytest module was used"
):
fake_pytest.main()
call_until(lambda: os.path.isfile(os.path.join(tmpdir, "hello.txt")))
suite = fake_pytest.main()
assert suite.countTestCases() == 1

def test_warns(self):
# success
Expand Down

0 comments on commit 838107e

Please sign in to comment.