File: __init__.py

package info (click to toggle)
dateparser 1.2.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,140 kB
  • sloc: python: 52,721; makefile: 155; sh: 15
file content (26 lines) | stat: -rw-r--r-- 749 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
from unittest import TestCase


class BaseTestCase(TestCase):
    def setUp(self):
        super().setUp()
        self.__patches = []

        self.error = NotImplemented

    def add_patch(self, patch):
        patch.start()
        self.__patches.append(patch)

    def tearDown(self):
        super().tearDown()
        for patch in reversed(self.__patches):
            patch.stop()

    def then_error_was_raised(self, error_cls, allowed_substrings=()):
        self.assertIsInstance(self.error, error_cls)
        self.assertTrue(
            any(mesg in str(self.error) for mesg in allowed_substrings),
            "Didn't found any of the expected messages (%r) -- message was: %r"
            % (allowed_substrings, self.error),
        )