restructure data types
This commit is contained in:
11
tests/fixtures.py
Normal file
11
tests/fixtures.py
Normal file
@ -0,0 +1,11 @@
|
||||
import pytest
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
@pytest.fixture
|
||||
def data_path():
|
||||
try:
|
||||
p = os.environ['CREADER_TEST_DATA']
|
||||
except KeyError:
|
||||
raise KeyError("CREADER_TEST_DATA needs to be set before running tests")
|
||||
return Path(p)
|
11
tests/test_ClusterReader.py
Normal file
11
tests/test_ClusterReader.py
Normal file
@ -0,0 +1,11 @@
|
||||
import pytest
|
||||
import os, sys
|
||||
from creader import ClusterFileReader
|
||||
from fixtures import data_path
|
||||
|
||||
def test_references_on_read(data_path):
|
||||
fname= (data_path/'beam_En700eV_-40deg_300V_10us_d0_f0_100.clust').as_posix()
|
||||
r = ClusterFileReader(fname)
|
||||
clusters = r.read(10)
|
||||
assert sys.getrefcount(clusters) == 2 #Over counts by one due to call by reference
|
||||
|
12
tests/test_functions.py
Normal file
12
tests/test_functions.py
Normal file
@ -0,0 +1,12 @@
|
||||
import pytest
|
||||
from fixtures import data_path
|
||||
from creader import ClusterFileReader, clusterize
|
||||
import sys
|
||||
|
||||
def test_references_on_clusterize(data_path):
|
||||
fname= (data_path/'beam_En700eV_-40deg_300V_10us_d0_f0_100.clust').as_posix()
|
||||
r = ClusterFileReader(fname)
|
||||
clusters = r.read(10)
|
||||
result = clusterize(clusters)
|
||||
assert sys.getrefcount(clusters) == 2 #Over counts by one due to call by reference
|
||||
assert sys.getrefcount(result) == 2
|
Reference in New Issue
Block a user