def test_level_error(self): ftc = FakeTestCase() logger = logging.getLogger() logassert.setup(ftc, '') logger.info("test") ftc.assertNotLoggedError("test") self.assertEqual(ftc.failed, None)
def test_assert_different_level_ok_warning(self): ftc = FakeTestCase() logger = logging.getLogger() logassert.setup(ftc, '') logger.warning("test") ftc.assertLoggedWarning("test") self.assertEqual(ftc.failed, None)
def test_simple_ok(self): ftc = FakeTestCase() logger = logging.getLogger() logassert.setup(ftc, '') logger.debug("test") ftc.assertNotLogged("other") self.assertEqual(ftc.failed, None)
def test_simple_assert_fail(self): ftc = FakeTestCase() logassert.setup(ftc, '') self.logger.debug("test") ftc.assertLogged("test2") self.assertEqual(ftc.failed, "Tokens ('test2',) not found, all was logged is...\n" " DEBUG 'test'")
def test_say_hi_on_first_install(self): mgr = PipManager(BIN_PATH, pip_installed=True, options=['--bar=baz']) with patch.object(helpers, 'logged_exec'): mgr.install('foo') self.assertLoggedInfo("Hi! This is fades") logassert.setup(self, 'fades.pipmanager') mgr.install('bar') self.assertNotLoggedInfo("Hi! This is fades")
def test_simple_assert_fail(self): ftc = FakeTestCase() logassert.setup(ftc, '') self.logger.debug("test") ftc.assertLogged("test2") self.assertEqual( ftc.failed, "Tokens ('test2',) not found, all was logged is...\n" " DEBUG 'test'")
def test_simple_assert_fail_with_replaces(self): ftc = FakeTestCase() logger = logging.getLogger() logassert.setup(ftc, '') logger.debug("test %d %r", 65, 'foobar') ftc.assertLogged("test", "pumba") self.assertEqual(ftc.failed, "Tokens ('test', 'pumba') not found, all was logged is...\n" " DEBUG \"test 65 'foobar'\"")
def test_assert_different_level_fail_oneway(self): ftc = FakeTestCase() logger = logging.getLogger() logassert.setup(ftc, '') logger.warning("test") ftc.assertLoggedDebug("test") self.assertEqual(ftc.failed, "Tokens ('test',) not found in DEBUG, all was logged is...\n" " WARNING 'test'")
def test_simple_fail(self): ftc = FakeTestCase() logger = logging.getLogger() logassert.setup(ftc, '') logger.info("test") ftc.assertNotLogged("test") self.assertEqual(ftc.failed, "Tokens ('test',) found in the following record: INFO 'test'")
def test_level_debug_fail(self): ftc = FakeTestCase() logger = logging.getLogger() logassert.setup(ftc, '') logger.debug("test") ftc.assertNotLoggedDebug("test") self.assertEqual(ftc.failed, "Tokens ('test',) found in the following record: DEBUG 'test'")
def test_simple_assert_ok_extras(self): ftc = FakeTestCase() logassert.setup(ftc, '') formatter = logging.Formatter("%(message)s %(foo)s") for h in self.logger.handlers: h.setFormatter(formatter) self.logger.debug("test", extra={'foo': 'bar'}) ftc.assertLogged("test bar") self.assertEqual(ftc.failed, None)
def setUp(self): # Source self.db = MemoryTLESource() self.db.add_tle(BUGSAT_SATE_ID, BUGSAT1_TLE_LINES, datetime.now()) # Predictor self.predictor = HighAccuracyTLEPredictor(BUGSAT_SATE_ID, self.db) self.is_ascending_mock = self._patch( 'orbit_predictor.accuratepredictor.LocationPredictor.is_ascending') self.start = datetime(2017, 3, 6, 7, 51) logassert.setup(self, 'orbit_predictor.accuratepredictor')
def setUp(self): # Source self.db = MemoryTLESource() self.db.add_tle(BUGSAT_SATE_ID, BUGSAT1_TLE_LINES, dt.datetime.utcnow()) # Predictor self.predictor = TLEPredictor(BUGSAT_SATE_ID, self.db) self.is_ascending_mock = self._patch( 'orbit_predictor.predictors.base.LocationPredictor._is_ascending') self.start = dt.datetime(2017, 3, 6, 7, 51) logassert.setup(self, 'orbit_predictor.predictors.pass_iterators')
def test_salutes_once(self): logger = log_set_up(verbose=False, quiet=False) logger.info("test foobar") self.assertLoggedInfo("Hi! This is fades") self.assertLoggedInfo("test foobar") # again, check this time it didn't salute, but original log message is ok logassert.setup(self, 'fades') logger.info("test barbarroja") self.assertNotLoggedInfo("Hi! This is fades") self.assertLoggedInfo("test barbarroja")
def test_assert_different_level_ok_exception(self): ftc = FakeTestCase() logger = logging.getLogger() logassert.setup(ftc, '') try: raise ValueError("test error") except: logger.exception("test message") ftc.assertLoggedError("test error") ftc.assertLoggedError("test message") ftc.assertLoggedError("ValueError") self.assertEqual(ftc.failed, None)
def test_avoid_delayed_messaging(self): ftc = FakeTestCase() logger = logging.getLogger() logassert.setup(ftc, '') class Exploding: """Explode on delayed str.""" should_explode = False def __str__(self): if self.should_explode: raise ValueError("str exploded") return "didn't explode" # log something using the Exploding class exploding = Exploding() logger.debug("feeling lucky? %s", exploding) # now flag the class to explode and check exploding.should_explode = True ftc.assertLogged("feeling lucky", "didn't explode")
def setUp(self): logassert.setup(self, '')
def setUp(self): logassert.setup(self, 'fades')
def setUp(self): super().setUp() logassert.setup(self, "")
def setUp(self): logassert.setup(self, 'fades.helpers') self.deps = parsing.parse_manual(["django==1.7.5", "requests"]) self.deps_higher = parsing.parse_manual(["django==100.1.1"]) self.deps_same_than_latest = parsing.parse_manual(["django==1.9"])
def test_simple_assert_ok_with_replaces(self): ftc = FakeTestCase() logassert.setup(ftc, '') self.logger.debug("test %d %r", 65, 'foobar') ftc.assertLogged("test", "65", "foobar") self.assertEqual(ftc.failed, None)
def test_get_handler(self): ftc = FakeTestCase() h = logassert.setup(ftc, '') self.assertIsInstance(h, logging.Handler)
def test_simple_assert_ok(self): ftc = FakeTestCase() logassert.setup(ftc, '') self.logger.debug("test") ftc.assertLogged("test") self.assertEqual(ftc.failed, None)
def setUp(self): logassert.setup(self, 'fades.parsing')
def setUp(self): logassert.setup(self, 'fades.helpers')
def setUp(self): logassert.setup(self, 'fades.pipmanager')
def setUp(self): logassert.setup(self, 'fades.envbuilder')
def setUp(self): logassert.setup(self, 'ops.lib')