Skip to content

Commit

Permalink
Fix bug when getting a repr of a timestep which is not attached to a …
Browse files Browse the repository at this point in the history
…session

Add test
  • Loading branch information
apontzen committed Oct 28, 2023
1 parent fc9e5a8 commit 6a5423d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
6 changes: 5 additions & 1 deletion tangos/core/timestep.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
9 changes: 9 additions & 0 deletions tests/test_timestep.py
Original file line number Diff line number Diff line change
@@ -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"

0 comments on commit 6a5423d

Please sign in to comment.