Skip to content

Commit

Permalink
Convert to pytest style
Browse files Browse the repository at this point in the history
  • Loading branch information
hugovk committed Nov 9, 2024
1 parent bf284ae commit 0444b48
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions tests/test_parser.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,28 @@
import glob
import os
import unittest

import pytest

from blurb.blurb import Blurbs, pushd


class TestParserPasses(unittest.TestCase):
class TestParserPasses:
directory = "tests/pass"

def filename_test(self, filename):
b = Blurbs()
b.load(filename)
self.assertTrue(b)
assert b
if os.path.exists(filename + ".res"):
with open(filename + ".res", encoding="utf-8") as file:
expected = file.read()
self.assertEqual(str(b), expected)
assert str(b) == expected

def test_files(self):
with pushd(self.directory):
for filename in glob.glob("*"):
if filename[-4:] == ".res":
self.assertTrue(os.path.exists(filename[:-4]), filename)
if filename.endswith(".res"):
assert os.path.exists(filename[:-4]), filename
continue
self.filename_test(filename)

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

def filename_test(self, filename):
b = Blurbs()
with self.assertRaises(Exception):
with pytest.raises(Exception):
b.load(filename)

0 comments on commit 0444b48

Please sign in to comment.