|
5 | 5 | from collections import OrderedDict
|
6 | 6 | from datetime import datetime, timedelta
|
7 | 7 | from unittest import TestCase
|
8 |
| -from warnings import warn, catch_warnings |
| 8 | +from warnings import catch_warnings, warn |
9 | 9 |
|
10 | 10 | from asserts import (
|
11 |
| - fail, |
12 |
| - assert_true, |
13 |
| - assert_false, |
14 |
| - assert_boolean_true, |
15 |
| - assert_boolean_false, |
16 |
| - assert_is_none, |
17 |
| - assert_is_not_none, |
18 |
| - assert_equal, |
19 |
| - assert_not_equal, |
| 11 | + Exists, |
20 | 12 | assert_almost_equal,
|
21 |
| - assert_not_almost_equal, |
| 13 | + assert_between, |
| 14 | + assert_boolean_false, |
| 15 | + assert_boolean_true, |
| 16 | + assert_count_equal, |
| 17 | + assert_datetime_about_now, |
| 18 | + assert_datetime_about_now_utc, |
22 | 19 | assert_dict_equal,
|
23 | 20 | assert_dict_superset,
|
24 |
| - assert_less, |
25 |
| - assert_less_equal, |
| 21 | + assert_equal, |
| 22 | + assert_false, |
26 | 23 | assert_greater,
|
27 | 24 | assert_greater_equal,
|
28 |
| - assert_between, |
| 25 | + assert_has_attr, |
| 26 | + assert_in, |
29 | 27 | assert_is,
|
| 28 | + assert_is_instance, |
| 29 | + assert_is_none, |
30 | 30 | assert_is_not,
|
31 |
| - assert_in, |
| 31 | + assert_is_not_none, |
| 32 | + assert_json_subset, |
| 33 | + assert_less, |
| 34 | + assert_less_equal, |
| 35 | + assert_not_almost_equal, |
| 36 | + assert_not_equal, |
32 | 37 | assert_not_in,
|
33 |
| - assert_count_equal, |
34 |
| - assert_regex, |
35 |
| - assert_is_instance, |
36 | 38 | assert_not_is_instance,
|
37 |
| - assert_has_attr, |
38 |
| - assert_datetime_about_now, |
39 |
| - assert_datetime_about_now_utc, |
| 39 | + assert_not_regex, |
40 | 40 | assert_raises,
|
41 |
| - assert_raises_regex, |
42 | 41 | assert_raises_errno,
|
| 42 | + assert_raises_regex, |
| 43 | + assert_regex, |
43 | 44 | assert_succeeds,
|
| 45 | + assert_true, |
44 | 46 | assert_warns,
|
45 | 47 | assert_warns_regex,
|
46 |
| - assert_json_subset, |
47 |
| - Exists, |
| 48 | + fail, |
48 | 49 | )
|
49 | 50 |
|
50 | 51 |
|
@@ -617,6 +618,49 @@ def test_assert_regex__does_not_match_regex__custom_message(self):
|
617 | 618 | ):
|
618 | 619 | assert_regex("Wrong text", regex, "{msg};{text!r};{pattern!r}")
|
619 | 620 |
|
| 621 | + # assert_not_regex() |
| 622 | + |
| 623 | + def test_assert_not_regex__does_not_match_string(self): |
| 624 | + assert_not_regex("This is a test text", "no match") |
| 625 | + |
| 626 | + def test_assert_not_regex__does_not_match_regex(self): |
| 627 | + regex = re.compile("no match") |
| 628 | + assert_not_regex("This is a test text", regex) |
| 629 | + |
| 630 | + def test_assert_not_regex__matches_string__default_message(self): |
| 631 | + with _assert_raises_assertion( |
| 632 | + "'This is a test text' matches 'is.*test'" |
| 633 | + ): |
| 634 | + assert_not_regex("This is a test text", "is.*test") |
| 635 | + |
| 636 | + def test_assert_not_regex__matches_regex__default_message(self): |
| 637 | + regex = re.compile("is.*test") |
| 638 | + with _assert_raises_assertion( |
| 639 | + "'This is a test text' matches 'is.*test'" |
| 640 | + ): |
| 641 | + assert_not_regex("This is a test text", regex) |
| 642 | + |
| 643 | + def test_assert_not_regex__matches_string__custom_message(self): |
| 644 | + with _assert_raises_assertion( |
| 645 | + "'This is a test text' matches 'is.*test';" |
| 646 | + "'This is a test text';'is.*test'" |
| 647 | + ): |
| 648 | + assert_not_regex( |
| 649 | + "This is a test text", |
| 650 | + "is.*test", |
| 651 | + "{msg};{text!r};{pattern!r}", |
| 652 | + ) |
| 653 | + |
| 654 | + def test_assert_not_regex__matches_regex__custom_message(self): |
| 655 | + regex = re.compile("is.*test") |
| 656 | + with _assert_raises_assertion( |
| 657 | + "'This is a test text' matches 'is.*test';'This is a test text';" |
| 658 | + "'is.*test'" |
| 659 | + ): |
| 660 | + assert_not_regex( |
| 661 | + "This is a test text", regex, "{msg};{text!r};{pattern!r}" |
| 662 | + ) |
| 663 | + |
620 | 664 | # assert_is()
|
621 | 665 |
|
622 | 666 | def test_assert_is__same(self):
|
|
0 commit comments