mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-07-07 20:06:39 +02:00
Replace assertRegexpMatches
with assertRegex
- #259 Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
This commit is contained in:
parent
9dd8257cc0
commit
34a152c794
8 changed files with 44 additions and 44 deletions
|
@ -52,7 +52,7 @@ class TestConfig(TestCase):
|
|||
def test_set_new_name_new_value(self):
|
||||
"""Test setting a new name, new value"""
|
||||
code, out, err = self.t("config name value :yes")
|
||||
self.assertRegexpMatches(out, r'^Config file .+ modified\.$')
|
||||
self.assertRegex(out, r'^Config file .+ modified\.$')
|
||||
|
||||
code, out, err = self.t("config")
|
||||
self.assertIn("name = value", out)
|
||||
|
@ -66,7 +66,7 @@ class TestConfig(TestCase):
|
|||
def test_set_new_name_same_value(self):
|
||||
"""Test setting a new name, same value"""
|
||||
code, out, err = self.t("config name value :yes")
|
||||
self.assertRegexpMatches(out, r'^Config file .+ modified\.$')
|
||||
self.assertRegex(out, r'^Config file .+ modified\.$')
|
||||
code, out, err = self.t("config")
|
||||
self.assertIn("name = value", out)
|
||||
|
||||
|
@ -77,7 +77,7 @@ class TestConfig(TestCase):
|
|||
def test_set_new_name_blank_value(self):
|
||||
"""Test setting a new name, blank value"""
|
||||
code, out, err = self.t("config name '' :yes")
|
||||
self.assertRegexpMatches(out, r'^Config file .+ modified\.$')
|
||||
self.assertRegex(out, r'^Config file .+ modified\.$')
|
||||
|
||||
code, out, err = self.t("config")
|
||||
self.assertIn("name = ", out)
|
||||
|
@ -85,10 +85,10 @@ class TestConfig(TestCase):
|
|||
def test_unset_new_name(self):
|
||||
"""Test unsetting a new name, no value"""
|
||||
code, out, err = self.t("config name value :yes")
|
||||
self.assertRegexpMatches(out, r'^Config file .+ modified\.$')
|
||||
self.assertRegex(out, r'^Config file .+ modified\.$')
|
||||
|
||||
code, out, err = self.t("config name :yes")
|
||||
self.assertRegexpMatches(out, r'^Config file .+ modified\.$')
|
||||
self.assertRegex(out, r'^Config file .+ modified\.$')
|
||||
|
||||
code, out, err = self.t("config")
|
||||
self.assertNotIn("name = ", out)
|
||||
|
@ -96,7 +96,7 @@ class TestConfig(TestCase):
|
|||
def test_set_new_hierarchical_name_new_value(self):
|
||||
"""Test setting a new hierarchical name, new value"""
|
||||
code, out, err = self.t("config foo.bar.baz value :yes")
|
||||
self.assertRegexpMatches(out, r'^Config file .+ modified\.$')
|
||||
self.assertRegex(out, r'^Config file .+ modified\.$')
|
||||
|
||||
code, out, err = self.t("config")
|
||||
self.assertIn("baz = value", out)
|
||||
|
@ -104,7 +104,7 @@ class TestConfig(TestCase):
|
|||
def test_set_new_hierarchical_name_same_value(self):
|
||||
"""Test setting a new hierarchical name, same value"""
|
||||
code, out, err = self.t("config foo.bar.baz value :yes")
|
||||
self.assertRegexpMatches(out, r'^Config file .+ modified\.$')
|
||||
self.assertRegex(out, r'^Config file .+ modified\.$')
|
||||
code, out, err = self.t("config")
|
||||
self.assertIn("baz = value", out)
|
||||
|
||||
|
@ -115,7 +115,7 @@ class TestConfig(TestCase):
|
|||
def test_set_new_hierarchical_name_blank_value(self):
|
||||
"""Test setting a new hierarchical name, blank value"""
|
||||
code, out, err = self.t("config foo.bar.baz '' :yes")
|
||||
self.assertRegexpMatches(out, r'^Config file .+ modified\.$')
|
||||
self.assertRegex(out, r'^Config file .+ modified\.$')
|
||||
|
||||
code, out, err = self.t("config")
|
||||
self.assertIn("baz = ", out)
|
||||
|
@ -123,10 +123,10 @@ class TestConfig(TestCase):
|
|||
def test_unset_new_hierarchical_name(self):
|
||||
"""Test unsetting a new hierarchical name, no value"""
|
||||
code, out, err = self.t("config foo.bar.baz value :yes")
|
||||
self.assertRegexpMatches(out, r'^Config file .+ modified\.$')
|
||||
self.assertRegex(out, r'^Config file .+ modified\.$')
|
||||
|
||||
code, out, err = self.t("config foo.bar.baz :yes")
|
||||
self.assertRegexpMatches(out, r'^Config file .+ modified\.$')
|
||||
self.assertRegex(out, r'^Config file .+ modified\.$')
|
||||
|
||||
code, out, err = self.t("config")
|
||||
self.assertNotIn("baz = ", out)
|
||||
|
@ -134,7 +134,7 @@ class TestConfig(TestCase):
|
|||
def test_set_known_name(self):
|
||||
"""Test setting a known name, new value"""
|
||||
code, out, err = self.t("config debug value :yes")
|
||||
self.assertRegexpMatches(out, r'^Config file .+ modified\.$')
|
||||
self.assertRegex(out, r'^Config file .+ modified\.$')
|
||||
|
||||
code, out, err = self.t("config")
|
||||
self.assertIn("debug = value", out)
|
||||
|
@ -142,7 +142,7 @@ class TestConfig(TestCase):
|
|||
def test_set_known_name_same_value(self):
|
||||
"""Test setting a known name, same value"""
|
||||
code, out, err = self.t("config debug value :yes")
|
||||
self.assertRegexpMatches(out, r'^Config file .+ modified\.$')
|
||||
self.assertRegex(out, r'^Config file .+ modified\.$')
|
||||
code, out, err = self.t("config")
|
||||
self.assertIn("debug = value", out)
|
||||
|
||||
|
@ -153,7 +153,7 @@ class TestConfig(TestCase):
|
|||
def test_set_known_name_blank_value(self):
|
||||
"""Test setting a known name, blank value"""
|
||||
code, out, err = self.t("config debug '' :yes")
|
||||
self.assertRegexpMatches(out, r'^Config file .+ modified\.$')
|
||||
self.assertRegex(out, r'^Config file .+ modified\.$')
|
||||
|
||||
code, out, err = self.t("config")
|
||||
self.assertIn("debug = ", out)
|
||||
|
@ -161,19 +161,19 @@ class TestConfig(TestCase):
|
|||
def test_unset_known_name(self):
|
||||
"""Test unsetting a known name"""
|
||||
code, out, err = self.t.runError("config debug :yes")
|
||||
self.assertRegexpMatches(err, r"No entry named 'debug' found\.\n$")
|
||||
self.assertRegex(err, r"No entry named 'debug' found\.\n$")
|
||||
|
||||
def test_reset_known_name(self):
|
||||
"""Test setting a known name"""
|
||||
code, out, err = self.t("config debug foo :yes")
|
||||
|
||||
code, out, err = self.t("config debug :yes")
|
||||
self.assertRegexpMatches(out, r'^Config file .+ modified\.$')
|
||||
self.assertRegex(out, r'^Config file .+ modified\.$')
|
||||
|
||||
def test_set_known_hierarchical_name(self):
|
||||
"""Test setting a known hierarchical name, new value"""
|
||||
code, out, err = self.t("config reports.day.month value :yes")
|
||||
self.assertRegexpMatches(out, r'^Config file .+ modified\.$')
|
||||
self.assertRegex(out, r'^Config file .+ modified\.$')
|
||||
|
||||
code, out, err = self.t("config")
|
||||
self.assertIn("month = value", out)
|
||||
|
@ -181,7 +181,7 @@ class TestConfig(TestCase):
|
|||
def test_set_known_hierarchical_name_same_value(self):
|
||||
"""Test setting a known hierarchical name, same value"""
|
||||
code, out, err = self.t("config reports.day.month value :yes")
|
||||
self.assertRegexpMatches(out, r'^Config file .+ modified\.$')
|
||||
self.assertRegex(out, r'^Config file .+ modified\.$')
|
||||
code, out, err = self.t("config")
|
||||
self.assertIn("month = value", out)
|
||||
|
||||
|
@ -192,7 +192,7 @@ class TestConfig(TestCase):
|
|||
def test_set_known_hierarchical_name_blank_value(self):
|
||||
"""Test setting a known hierarchical name, blank value"""
|
||||
code, out, err = self.t("config reports.day.month '' :yes")
|
||||
self.assertRegexpMatches(out, r'^Config file .+ modified\.$')
|
||||
self.assertRegex(out, r'^Config file .+ modified\.$')
|
||||
|
||||
code, out, err = self.t("config")
|
||||
self.assertIn("month = ", out)
|
||||
|
@ -200,14 +200,14 @@ class TestConfig(TestCase):
|
|||
def test_unset_known_hierarchical_name(self):
|
||||
"""Test unsetting a known hierarchical name"""
|
||||
code, out, err = self.t.runError("config reports.day.month :yes")
|
||||
self.assertRegexpMatches(err, r"^No entry named 'reports.day.month' found\.\n$")
|
||||
self.assertRegex(err, r"^No entry named 'reports.day.month' found\.\n$")
|
||||
|
||||
def test_reset_known_hierarchical_name(self):
|
||||
"""Test resetting a known hierarchical name"""
|
||||
code, out, err = self.t("config reports.day.month foo :yes")
|
||||
|
||||
code, out, err = self.t("config reports.day.month :yes")
|
||||
self.assertRegexpMatches(out, r'^Config file .+ modified\.$')
|
||||
self.assertRegex(out, r'^Config file .+ modified\.$')
|
||||
|
||||
def test_number_to_date_upgrade(self):
|
||||
"""Test that an integer remains an integer"""
|
||||
|
|
18
test/dom.t
18
test/dom.t
|
@ -122,7 +122,7 @@ class TestDOM(TestCase):
|
|||
"""Test dom.active.start with active track"""
|
||||
self.t("start one two")
|
||||
code, out, err = self.t("get dom.active.start")
|
||||
self.assertRegexpMatches(out, r'\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}')
|
||||
self.assertRegex(out, r'\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}')
|
||||
|
||||
def test_dom_active_duration_inactive(self):
|
||||
"""Test dom.active.duration with no active track"""
|
||||
|
@ -133,7 +133,7 @@ class TestDOM(TestCase):
|
|||
"""Test dom.active.duration with active track"""
|
||||
self.t("start one two")
|
||||
code, out, err = self.t("get dom.active.duration")
|
||||
self.assertRegexpMatches(out, r'PT\d+S')
|
||||
self.assertRegex(out, r'PT\d+S')
|
||||
|
||||
def test_dom_active_json_inactive(self):
|
||||
"""Test dom.active.json without an active interval"""
|
||||
|
@ -144,7 +144,7 @@ class TestDOM(TestCase):
|
|||
"""Test dom.active.json with an active interval"""
|
||||
self.t("start foo")
|
||||
code, out, err = self.t("get dom.active.json")
|
||||
self.assertRegexpMatches(out, r'{"start":"\d{8}T\d{6}Z","tags":\["foo"\]}')
|
||||
self.assertRegex(out, r'{"start":"\d{8}T\d{6}Z","tags":\["foo"\]}')
|
||||
|
||||
def test_dom_tracked_count_none(self):
|
||||
"""Test dom.active without an active interval"""
|
||||
|
@ -196,7 +196,7 @@ class TestDOMTracked(TestCase):
|
|||
def test_dom_tracked_N_start_active(self):
|
||||
"""Test dom.tracked.N.start with active track"""
|
||||
code, out, err = self.t("get dom.tracked.1.start")
|
||||
self.assertRegexpMatches(out, r'\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}')
|
||||
self.assertRegex(out, r'\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}')
|
||||
|
||||
def test_dom_tracked_N_end_invalid(self):
|
||||
"""Test dom.tracked.N.end with no active track"""
|
||||
|
@ -206,7 +206,7 @@ class TestDOMTracked(TestCase):
|
|||
def test_dom_tracked_N_end_inactive(self):
|
||||
"""Test dom.tracked.N.end with active track"""
|
||||
code, out, err = self.t("get dom.tracked.2.end")
|
||||
self.assertRegexpMatches(out, r'\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}')
|
||||
self.assertRegex(out, r'\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}')
|
||||
|
||||
def test_dom_tracked_N_end_active(self):
|
||||
"""Test dom.tracked.N.end with active track"""
|
||||
|
@ -216,22 +216,22 @@ class TestDOMTracked(TestCase):
|
|||
def test_dom_tracked_N_duration_inactive(self):
|
||||
"""Test dom.tracked.N.duration of closed track"""
|
||||
code, out, err = self.t("get dom.tracked.2.duration")
|
||||
self.assertRegexpMatches(out, r'P1D')
|
||||
self.assertRegex(out, r'P1D')
|
||||
|
||||
def test_dom_tracked_N_duration_active(self):
|
||||
"""Test dom.tracked.N.duration with open track"""
|
||||
code, out, err = self.t("get dom.tracked.1.duration")
|
||||
self.assertRegexpMatches(out, r'PT\d+S')
|
||||
self.assertRegex(out, r'PT\d+S')
|
||||
|
||||
def test_dom_tracked_N_json_inactive(self):
|
||||
"""Test dom.tracked.N.json of closed track"""
|
||||
code, out, err = self.t("get dom.tracked.2.json")
|
||||
self.assertRegexpMatches(out, r'{"start":"\d{8}T\d{6}Z","end":"\d{8}T\d{6}Z","tags":\["one","two"\]}')
|
||||
self.assertRegex(out, r'{"start":"\d{8}T\d{6}Z","end":"\d{8}T\d{6}Z","tags":\["one","two"\]}')
|
||||
|
||||
def test_dom_tracked_N_json_active(self):
|
||||
"""Test dom.tracked.N.json of open track"""
|
||||
code, out, err = self.t("get dom.tracked.1.json")
|
||||
self.assertRegexpMatches(out, r'{"start":"\d{8}T\d{6}Z"}')
|
||||
self.assertRegex(out, r'{"start":"\d{8}T\d{6}Z"}')
|
||||
|
||||
|
||||
class TestDOMRC(TestCase):
|
||||
|
|
|
@ -46,14 +46,14 @@ class TestGaps(TestCase):
|
|||
def test_trivial_gaps(self):
|
||||
"""Test trivial track"""
|
||||
code, out, err = self.t("gaps")
|
||||
self.assertRegexpMatches(out, r'\s{30}24:00:00')
|
||||
self.assertRegex(out, r'\s{30}24:00:00')
|
||||
|
||||
def test_single_unobstructed_interval(self):
|
||||
"""Add one interval and export it as-is"""
|
||||
self.t("track 20160527T080000 - 20160527T200000 foo")
|
||||
|
||||
code, out, err = self.t("gaps 2016-05-27 - 2016-05-28")
|
||||
self.assertRegexpMatches(out, r'\s{30}12:00:00')
|
||||
self.assertRegex(out, r'\s{30}12:00:00')
|
||||
|
||||
def test_single_unobstructed_interval_with_exclusions(self):
|
||||
"""Add one interval, with exclusions"""
|
||||
|
@ -62,7 +62,7 @@ class TestGaps(TestCase):
|
|||
self.t("track 20160527T100000 - 20160527T140000 foo")
|
||||
|
||||
code, out, err = self.t("gaps 2016-05-27 - 2016-05-28")
|
||||
self.assertRegexpMatches(out, r'\s{30}5:00:00')
|
||||
self.assertRegex(out, r'\s{30}5:00:00')
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
|
@ -44,7 +44,7 @@ class TestHelp(TestCase):
|
|||
def test_help_without_command_should_print_usage(self):
|
||||
"""timew help without command should print usage"""
|
||||
code, out, err = self.t("help")
|
||||
self.assertRegexpMatches(out, r"Usage: timew [--version]")
|
||||
self.assertRegex(out, r"Usage: timew [--version]")
|
||||
|
||||
def test_help_long_option_should_print_usage(self):
|
||||
"""timew --help should print usage"""
|
||||
|
@ -64,12 +64,12 @@ class TestHelp(TestCase):
|
|||
# Some versions of man have bug that displays following on stderr:
|
||||
# doc/man1/timew-shorten.1.in: ignoring bogus filename
|
||||
# Just check that stdout is correct here.
|
||||
self.assertRegexpMatches(out, r"timew-start\(1\)\s+User Manuals\s+timew-start\(1\)")
|
||||
self.assertRegex(out, r"timew-start\(1\)\s+User Manuals\s+timew-start\(1\)")
|
||||
|
||||
def test_help_with_unknown_argument_should_show_error_message(self):
|
||||
"""timew help with unknown argument should show error message"""
|
||||
code, out, err = self.t("help bogus")
|
||||
self.assertRegexpMatches(err, r"No manual entry for timew-bogus")
|
||||
self.assertRegex(err, r"No manual entry for timew-bogus")
|
||||
|
||||
def test_command_with_help_long_option_should_show_help_page(self):
|
||||
"""timew command with --help should show help page"""
|
||||
|
|
|
@ -75,7 +75,7 @@ class TestMove(TestCase):
|
|||
|
||||
self.t("start 5mins ago foo")
|
||||
code, out, err = self.t("move @1 {:%Y-%m-%dT%H}:01:23".format(one_hour_before))
|
||||
self.assertRegexpMatches(out, "Moved @1 to {:%Y-%m-%dT%H}:01:23".format(one_hour_before))
|
||||
self.assertRegex(out, "Moved @1 to {:%Y-%m-%dT%H}:01:23".format(one_hour_before))
|
||||
|
||||
j = self.t.export()
|
||||
|
||||
|
@ -86,7 +86,7 @@ class TestMove(TestCase):
|
|||
"""Move an open interval backwards in time"""
|
||||
self.t("start 5mins ago foo")
|
||||
code, out, err = self.t("move @1 today")
|
||||
self.assertRegexpMatches(out, 'Moved @1 to \d\d\d\d-\d\d-\d\dT00:00:00')
|
||||
self.assertRegex(out, 'Moved @1 to \d\d\d\d-\d\d-\d\dT00:00:00')
|
||||
|
||||
j = self.t.export()
|
||||
|
||||
|
@ -99,7 +99,7 @@ class TestMove(TestCase):
|
|||
|
||||
code, out, err = self.t("move @1 today")
|
||||
|
||||
self.assertRegexpMatches(out, 'Moved @1 to \d\d\d\d-\d\d-\d\dT00:00:00')
|
||||
self.assertRegex(out, 'Moved @1 to \d\d\d\d-\d\d-\d\dT00:00:00')
|
||||
|
||||
j = self.t.export()
|
||||
self.assertEqual(len(j), 1)
|
||||
|
@ -112,7 +112,7 @@ class TestMove(TestCase):
|
|||
|
||||
code, out, err = self.t("move @1 20170301T133000Z :adjust")
|
||||
|
||||
self.assertRegexpMatches(out, 'Moved @1 to 2017-03-01T\d\d:\d\d:\d\d\n')
|
||||
self.assertRegex(out, 'Moved @1 to 2017-03-01T\d\d:\d\d:\d\d\n')
|
||||
|
||||
j = self.t.export()
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ class TestSummary(TestCase):
|
|||
|
||||
code, out, err = self.t("summary :ids {:%Y-%m-%d} - {:%Y-%m-%d}".format(yesterday, tomorrow))
|
||||
|
||||
self.assertRegexpMatches(out, """
|
||||
self.assertRegex(out, """
|
||||
Wk ?Date Day ID Tags ?Start ?End Time Total
|
||||
[ -]+
|
||||
W\d{1,2} \d{4}-\d{2}-\d{2} .{3} @1 ?\d{1,2}:\d{2}:\d{2} \d{1,2}:\d{2}:\d{2} \d{1,2}:\d{2}:\d{2} \d{1,2}:\d{2}:\d{2}(
|
||||
|
@ -77,7 +77,7 @@ W\d{1,2} \d{4}-\d{2}-\d{2} .{3} @1 ?\d{1,2}:\d{2}:\d{2} \d{1,2}:\d{2}:\d{2
|
|||
|
||||
code, out, err = self.t("summary :ids {:%Y-%m-%d} - {:%Y-%m-%d}".format(yesterday, tomorrow))
|
||||
|
||||
self.assertRegexpMatches(out, """
|
||||
self.assertRegex(out, """
|
||||
Wk ?Date Day ID Tags ?Start End Time Total
|
||||
[ -]+
|
||||
W\d{1,2} \d{4}-\d{2}-\d{2} .{3} @1 ?\d{1,2}:\d{2}:\d{2}[ ]+- \d{1,2}:\d{2}:\d{2} \d{1,2}:\d{2}:\d{2}(
|
||||
|
@ -197,7 +197,7 @@ W10 2017-03-11 Sat @3 FOO 10:00:00 11:00:00 1:00:00
|
|||
"""Summary should display empty intervals at midnight"""
|
||||
self.t("track sod - sod")
|
||||
code, out, err = self.t("summary :year")
|
||||
self.assertRegexpMatches(out, """
|
||||
self.assertRegex(out, """
|
||||
Wk ?Date Day Tags ?Start ?End Time Total
|
||||
[ -]+
|
||||
W\d{1,2} \d{4}-\d{2}-\d{2} .{3} ?0:00:00 0:00:00 0:00:00 0:00:00
|
||||
|
|
|
@ -50,7 +50,7 @@ from basetest import Timew, TestCase
|
|||
# self.assertIn(substring, text)
|
||||
# self.assertNotIn(substring, text
|
||||
# self.assertRaises(e)
|
||||
# self.assertRegexpMatches(text, pattern)
|
||||
# self.assertRegex(text, pattern)
|
||||
# self.assertNotRegexpMatches(text, pattern)
|
||||
# self.tap("")
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ class TestVersion(TestCase):
|
|||
def test_version_option(self):
|
||||
"""Verify that 'timew --version' returns something valid"""
|
||||
code, out, err = self.t("--version")
|
||||
self.assertRegexpMatches(out, r'^\d\.\d+\.\d+(\.\w+)?$')
|
||||
self.assertRegex(out, r'^\d\.\d+\.\d+(\.\w+)?$')
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue