Skip to content

Move blurb test subcommand into test suite #37

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 6, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Convert to pytest style
  • Loading branch information
hugovk committed Nov 9, 2024
commit 0444b4809c1f444001d94c779438b6059317b66d
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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy