2019-03-13 21:17:08 +00:00
|
|
|
|
|
|
|
from trick.unit_test import *
|
|
|
|
|
|
|
|
def main():
|
|
|
|
trick.stop(1.0)
|
|
|
|
trick_utest.unit_tests.enable()
|
|
|
|
trick_utest.unit_tests.set_file_name( os.getenv("TRICK_HOME") + "/trick_test/SIM_python_namespace.xml" )
|
|
|
|
trick_utest.unit_tests.set_test_name( "PythonNamespace" )
|
|
|
|
test_suite = "python_namespace"
|
|
|
|
|
|
|
|
# normal class methods from S_define
|
|
|
|
ball.foo_food.print_me()
|
|
|
|
ball.foo_inner_food.print_me()
|
|
|
|
ball.bar_food.print_me()
|
2019-03-14 14:33:50 +00:00
|
|
|
ball.foo_yummyfood.print_me()
|
2019-03-13 21:17:08 +00:00
|
|
|
print
|
|
|
|
|
|
|
|
# new class from Foo.Food
|
|
|
|
food = trick.Foo.Food()
|
|
|
|
food.print_me()
|
|
|
|
TRICK_EXPECT_EQ( food.fast , 0, test_suite , "first level python namespace" )
|
|
|
|
food.fast = trick.Foo.Burger
|
|
|
|
TRICK_EXPECT_EQ( food.fast , 2, test_suite , "first level python namespace" )
|
|
|
|
|
|
|
|
# new class from Foo.Food.Inner
|
|
|
|
foodinner = trick.Foo.Inner.Food()
|
|
|
|
foodinner.print_me()
|
|
|
|
TRICK_EXPECT_EQ( foodinner.fast , 1, test_suite , "second level python namespace" )
|
|
|
|
foodinner.fast = trick.Foo.Inner.Burger
|
|
|
|
TRICK_EXPECT_EQ( foodinner.fast , 0, test_suite , "second level python namespace" )
|
|
|
|
|
|
|
|
# new class from Foo.Food.Inner
|
|
|
|
bar = trick.Bar.Food()
|
|
|
|
bar.print_me()
|
|
|
|
TRICK_EXPECT_EQ( bar.fast , 2, test_suite , "another first level python namespace" )
|
|
|
|
bar.fast = trick.Bar.Burger
|
|
|
|
TRICK_EXPECT_EQ( bar.fast , 1, test_suite , "another first level python namespace" )
|
|
|
|
|
2019-03-14 14:33:50 +00:00
|
|
|
# new class from Foo.Food.Inner
|
|
|
|
yummy = trick.Foo.YummyFood()
|
|
|
|
yummy.print_me()
|
|
|
|
TRICK_EXPECT_EQ( yummy.yummy , 1, test_suite , "additional file in same namespace" )
|
|
|
|
yummy.yummy = trick.Foo.Doughnuts
|
|
|
|
TRICK_EXPECT_EQ( yummy.yummy , 2, test_suite , "additional file in same namespace" )
|
|
|
|
|
2023-01-23 14:50:13 +00:00
|
|
|
# new class from TrickFood
|
|
|
|
trickfood = trick.Food()
|
|
|
|
trickfood.print_me()
|
|
|
|
TRICK_EXPECT_EQ( trickfood.fast , 2, test_suite , "blank python_module statement" )
|
|
|
|
trickfood.fast = trick.Pizza
|
|
|
|
TRICK_EXPECT_EQ( trickfood.fast , 0, test_suite , "blank python_module statement" )
|
|
|
|
|
2019-03-13 21:17:08 +00:00
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|
|
|
|
|
|
|
|
|