Skip to content

Commit

Permalink
tests: fixed the test that creates initial settings files
Browse files Browse the repository at this point in the history
  • Loading branch information
Ken Kundert authored and Ken Kundert committed Sep 4, 2021
1 parent 25005d0 commit 4a7382f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
2 changes: 2 additions & 0 deletions tests/test-cases.nt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ emborg without configs:
args: version
expected: emborg version: \d+\.\d+\.\d+ \(\d\d\d\d-\d\d-\d\d\) \[Python \d\.\d+\.\d+\]\.
expected_type: regex
remove: .config

-
args: help
Expand Down Expand Up @@ -160,6 +161,7 @@ emborg without configs:
> 0077)

-
args:
expected:
> Configuration directory created: /«TESTS»/.config/emborg.
> Includes example settings files. Edit them to suit your needs.
Expand Down
14 changes: 8 additions & 6 deletions tests/test_emborg.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

# schema for test cases {{{2
emborg_schema = Schema({
Optional('args', default=[]): Any(str, list),
Optional('args', default='<PASS>'): Any(str, list),
Optional('expected', default=""): str,
Optional('expected_type', default=""): str,
Optional('cmp_dirs', default=""): str,
Expand Down Expand Up @@ -76,17 +76,19 @@ def __init__(self, args, expected, expected_type, cmp_dirs, remove):

# expand «TESTS» and «DATE»
date = arrow.now().format("YYYY-MM-DD")
if args:
args = args.replace("«TESTS»", tests_dir_wo_slash)
args = args.replace("«DATE»", date)

# replace «TESTS» and «DATE» macros
args = args.split() if is_str(args) else args
args = [a.replace("«TESTS»", tests_dir_wo_slash) for a in args]
args = [a.replace("«DATE»", date) for a in args]
if expected is not None:
expected = expected.replace("«TESTS»", tests_dir_wo_slash)
expected = expected.replace("«DATE»", date)
if cmp_dirs:
cmp_dirs = cmp_dirs.replace("«TESTS»", tests_dir_wo_slash)
cmp_dirs = cmp_dirs.replace("«DATE»", date)

self.args = args.split() if is_str(args) else args
self.args = args
self.expected = expected.strip("\n")
self.expected_type = expected_type.split()
self.cmp_dirs = cmp_dirs.split() if is_str(cmp_dirs) else cmp_dirs
Expand All @@ -100,7 +102,7 @@ def run(self):
# remove requested files and directories
if self.remove:
rm(self.remove.split())
if not self.args:
if '<PASS>' in self.args:
return True

# run command
Expand Down

0 comments on commit 4a7382f

Please sign in to comment.