def f(x): try: from foo import Bar #pass except ImportError: class Bar(object): pass return Bar()
from foo import Boo from foo import Bar boo = Boo() bar = Bar() boo.printBoo() bar.printBar()
#!/bin/env python3 import car_in_abs from car_in_abs import Skoda as Mycar from foo import Bar skoda = car_in_abs.Skoda() skoda.showName() mycar = Mycar() mycar.showName() bar = Bar() bar.hello()
def test_copyable(): copybar = Bar(UMSCM({"foo": 42, "bar": -1})) assert dict(copybar.m_map) == {"foo": 42, "bar": -1} copybar.m_map["foo"] = -1 copybar.m_map["baz"] = 1337 assert dict(copybar.m_map) == {"foo": -1, "bar": -1, "baz": 1337}
def test_moveonly(): movebar = Bar("foo", 42) # this makes a MoveOnlyMemberMap assert movebar.m_map # we can only assert that the member map exists
def test_bar_get(self): self.assertIsInstance(Bar.bar_get(), foo.Bar)