Coverage for tests/test_shadowing.py : 38%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
# This file is part of astro_metadata_translator. # # Developed for the LSST Data Management System. # This product includes software developed by the LSST Project # (http://www.lsst.org). # See the LICENSE file at the top-level directory of this distribution # for details of code ownership. # # Use of this source code is governed by a 3-clause BSD-style # license that can be found in the LICENSE file.
return "BaseInstrument"
# This should not pick up the _const_map from parent class
# The explicit method should override the parent implementations # and not inherit the _trivial_map from parent. return "InstrumentE"
with self.assertLogs("astro_metadata_translator", level="WARN") as cm: class ShadowTranslator(StubTranslator): _const_map = {"instrument": "InstrumentC"} _trivial_map = {"instrument": "INSTRUME"}
def to_instrument(self): return "Instrument3"
self.assertIn("defined in both", cm.output[0]) self.assertIn("replaced by _const_map", cm.output[1])
s = ShadowTranslator({}) self.assertEqual(s.to_instrument(), "InstrumentC")
with self.assertLogs("astro_metadata_translator", level="WARN") as cm: class ShadowTranslator(StubTranslator): _trivial_map = {"instrument": "INSTRUME"}
def to_instrument(self): return "Instrument3"
self.assertIn("replaced by _trivial_map", cm.output[0])
s = ShadowTranslator({"INSTRUME": "InstrumentT"}) self.assertEqual(s.to_instrument(), "InstrumentT")
t = TrivialTranslator({"INSTRUME": "InstrumentX"}) self.assertEqual(t.to_instrument(), "InstrumentX")
t = ExplicitTranslator({}) self.assertEqual(t.to_instrument(), "InstrumentE")
unittest.main() |