-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move 'blurb test' subcommand into test suite (#37)
- Loading branch information
Showing
4 changed files
with
38 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,3 +10,4 @@ exclude_also = | |
[run] | ||
omit = | ||
**/blurb/__main__.py | ||
**/blurb/_version.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import glob | ||
import os | ||
|
||
import pytest | ||
|
||
from blurb.blurb import Blurbs, pushd | ||
|
||
|
||
class TestParserPasses: | ||
directory = "tests/pass" | ||
|
||
def filename_test(self, filename): | ||
b = Blurbs() | ||
b.load(filename) | ||
assert b | ||
if os.path.exists(filename + ".res"): | ||
with open(filename + ".res", encoding="utf-8") as file: | ||
expected = file.read() | ||
assert str(b) == expected | ||
|
||
def test_files(self): | ||
with pushd(self.directory): | ||
for filename in glob.glob("*"): | ||
if filename.endswith(".res"): | ||
assert os.path.exists(filename[:-4]), filename | ||
continue | ||
self.filename_test(filename) | ||
|
||
|
||
class TestParserFailures(TestParserPasses): | ||
directory = "tests/fail" | ||
|
||
def filename_test(self, filename): | ||
b = Blurbs() | ||
with pytest.raises(Exception): | ||
b.load(filename) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters