Skip to content

Commit 0444b48

Browse files
committed
Convert to pytest style
1 parent bf284ae commit 0444b48

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

tests/test_parser.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,28 @@
11
import glob
22
import os
3-
import unittest
3+
4+
import pytest
45

56
from blurb.blurb import Blurbs, pushd
67

78

8-
class TestParserPasses(unittest.TestCase):
9+
class TestParserPasses:
910
directory = "tests/pass"
1011

1112
def filename_test(self, filename):
1213
b = Blurbs()
1314
b.load(filename)
14-
self.assertTrue(b)
15+
assert b
1516
if os.path.exists(filename + ".res"):
1617
with open(filename + ".res", encoding="utf-8") as file:
1718
expected = file.read()
18-
self.assertEqual(str(b), expected)
19+
assert str(b) == expected
1920

2021
def test_files(self):
2122
with pushd(self.directory):
2223
for filename in glob.glob("*"):
23-
if filename[-4:] == ".res":
24-
self.assertTrue(os.path.exists(filename[:-4]), filename)
24+
if filename.endswith(".res"):
25+
assert os.path.exists(filename[:-4]), filename
2526
continue
2627
self.filename_test(filename)
2728

@@ -31,5 +32,5 @@ class TestParserFailures(TestParserPasses):
3132

3233
def filename_test(self, filename):
3334
b = Blurbs()
34-
with self.assertRaises(Exception):
35+
with pytest.raises(Exception):
3536
b.load(filename)

0 commit comments

Comments
 (0)