diff --git a/tangos/core/timestep.py b/tangos/core/timestep.py index 7c28102d..d45bd21f 100644 --- a/tangos/core/timestep.py +++ b/tangos/core/timestep.py @@ -76,8 +76,12 @@ def __getitem__(self, halo_identifier): @property def path(self): - with Session.object_session(self).no_autoflush: + sess = Session.object_session(self) + if sess is None: return self.simulation.path+"/"+self.extension + else: + with sess.no_autoflush: + return self.simulation.path+"/"+self.extension @property def redshift_cascade(self): diff --git a/tests/test_timestep.py b/tests/test_timestep.py new file mode 100644 index 00000000..e9dc8429 --- /dev/null +++ b/tests/test_timestep.py @@ -0,0 +1,9 @@ +import tangos +from tangos import testing + +def setup_module(): + testing.init_blank_db_for_testing() +def test_timestep_formatter(): + sim = tangos.core.Simulation('test_sim') + ts = tangos.core.TimeStep(sim, "test_timestep") + assert ts.path=="test_sim/test_timestep" \ No newline at end of file