Skip to content

Commit

Permalink
rearrange test to use a pytest.fixture
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric G. Stern committed Jun 28, 2024
1 parent d9203a8 commit 3cd124a
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/synergia/simulation/tests/test_iota_elem_lengths.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,8 @@
################################################################################


def get_lattice():
@pytest.fixture
def lattice_fixture():
# read the lattice in from a MadX sequence file

reader = synergia.lattice.MadX_reader()
Expand Down Expand Up @@ -396,9 +397,8 @@ def get_propagator(lattice):

################################################################################

def test_elem_lengths():
# get the lattice
lattice = get_lattice()
def test_elem_lengths(lattice_fixture):
lattice = lattice_fixture
lattice_length = lattice.get_length()

refpart = lattice.get_reference_particle()
Expand Down Expand Up @@ -459,7 +459,8 @@ def step_end_action(sim, inlattice, turn, step):
assert element_lengths[i] == pytest.approx(context.elem_cdt[i]*beta)

def main():
test_elem_lengths()
lf = lattice_fixture()
test_elem_lengths(lf)

if __name__ == "__main__":
main()

0 comments on commit 3cd124a

Please sign in to comment.