forked from M-Labs/artiq
1
0
Fork 0

added test case for get_experiment() with nested class

Signed-off-by: Leon Riesebos <leon.riesebos@duke.edu>
This commit is contained in:
Leon Riesebos 2021-02-27 16:22:32 -05:00 committed by Sébastien Bourdeauducq
parent 1deaa758ce
commit b8f4c6b9bb
1 changed files with 23 additions and 0 deletions

View File

@ -116,3 +116,26 @@ class Exp1(EnvExperiment):
# by elimination # by elimination
self.assertIs(mod.Exp1, tools.get_experiment(mod)) self.assertIs(mod.Exp1, tools.get_experiment(mod))
def test_nested_experiment(self):
with create_modules(MODNAME) as mods:
with mods[MODNAME].open("a") as fp:
print(
"""
from artiq.experiment import *
class Foo:
class Exp1(EnvExperiment):
pass
""",
file=fp,
)
mod = tools.file_import(str(mods[MODNAME]))
# by class name
self.assertIs(mod.Foo.Exp1, tools.get_experiment(mod, "Foo.Exp1"))
# by elimination should fail
with self.assertRaises(ValueError):
tools.get_experiment(mod)