Skip to content

Commit 2c4ec0b

Browse files
fixed test
1 parent f5c66c4 commit 2c4ec0b

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

tests/atm.automaton

-3.53 KB
Binary file not shown.

tests/test_module_primer_screen.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
# -*- coding: utf-8 -*-
33

44
import pytest
5+
import tempfile
56
import pickle
67
import ahocorasick
78
from pydna.readers import read
8-
from pydna_utils.myprimers import PrimerList
99
from pydna.amplify import pcr
1010

1111
from pydna.primer_screen import make_automaton
@@ -16,7 +16,6 @@
1616
from pydna.primer_screen import diff_primer_pairs
1717
from pydna.primer_screen import diff_primer_triplets
1818

19-
2019
from 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

6169
def test_diff_primer_pairs():

0 commit comments

Comments
 (0)