2
0
mirror of https://github.com/m-labs/artiq.git synced 2024-12-26 03:38:25 +08:00

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

View File

@ -116,3 +116,26 @@ class Exp1(EnvExperiment):
# by elimination
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)