aports/community/twine/test-setup.patch
2024-03-28 14:54:43 +01:00

37 lines
1.5 KiB
Diff

use a pytest fixture instead
diff --git a/tests/test_check.py b/tests/test_check.py
index d83f29e..9dac9bd 100644
--- a/tests/test_check.py
+++ b/tests/test_check.py
@@ -24,16 +24,17 @@ from twine.commands import check
class TestWarningStream:
- def setup(self):
- self.stream = check._WarningStream()
+ @pytest.fixture
+ def stream(self):
+ return check._WarningStream()
- def test_write_match(self):
- self.stream.write("<string>:2: (WARNING/2) Title underline too short.")
- assert self.stream.getvalue() == "line 2: Warning: Title underline too short.\n"
+ def test_write_match(self, stream):
+ stream.write("<string>:2: (WARNING/2) Title underline too short.")
+ assert stream.getvalue() == "line 2: Warning: Title underline too short.\n"
- def test_write_nomatch(self):
- self.stream.write("this does not match")
- assert self.stream.getvalue() == "this does not match"
+ def test_write_nomatch(self, stream):
+ stream.write("this does not match")
+ assert stream.getvalue() == "this does not match"
- def test_str_representation(self):
- self.stream.write("<string>:2: (WARNING/2) Title underline too short.")
- assert str(self.stream) == "line 2: Warning: Title underline too short."
+ def test_str_representation(self, stream):
+ stream.write("<string>:2: (WARNING/2) Title underline too short.")
+ assert str(stream) == "line 2: Warning: Title underline too short."