File tree Expand file tree Collapse file tree 2 files changed +12
-4
lines changed Expand file tree Collapse file tree 2 files changed +12
-4
lines changed Original file line number Diff line number Diff line change 22# -*- coding: utf-8 -*-
33
44import pytest
5+ import tempfile
56import pickle
67import ahocorasick
78from pydna .readers import read
8- from pydna_utils .myprimers import PrimerList
99from pydna .amplify import pcr
1010
1111from pydna .primer_screen import make_automaton
1616from pydna .primer_screen import diff_primer_pairs
1717from pydna .primer_screen import diff_primer_triplets
1818
19-
2019from pydna .parsers import parse_primers
2120
2221
@@ -53,9 +52,18 @@ def test_automaton():
5352
5453 atm = make_automaton (pl )
5554
56- atm .save ("atm.automaton" , pickle .dumps )
55+ with tempfile .NamedTemporaryFile () as tmp :
56+ # Save automaton to temporary file
57+ atm .save (tmp .name , pickle .dumps )
58+ tmp .flush ()
59+
60+ # Load it back from the same file
61+ atm2 = ahocorasick .load (tmp .name , pickle .loads )
5762
58- atm = ahocorasick .load ("atm.automaton" , pickle .loads )
63+ # Verify that loading worked
64+ assert atm2 is not None
65+ assert [x for x in atm2 .keys ()] == [x for x in atm .keys ()]
66+ assert [x for x in atm2 .values ()] == [x for x in atm .values ()]
5967
6068
6169def test_diff_primer_pairs ():
You can’t perform that action at this time.
0 commit comments