reader accept Path obj
This commit is contained in:
@ -4,6 +4,26 @@ from creader import ClusterFileReader
|
||||
from fixtures import data_path
|
||||
import numpy as np
|
||||
|
||||
def test_open_file_using_Path(data_path):
|
||||
# C extension cannot directly parse pathlib.Path to char *
|
||||
# Check that implementation is working
|
||||
try:
|
||||
fname= data_path/'beam_En700eV_-40deg_300V_10us_d0_f0_100.clust'
|
||||
r = ClusterFileReader(fname)
|
||||
assert r.read(10).size == 10 # Read to make sure file is really open
|
||||
|
||||
except:
|
||||
pytest.fail("Could not open file using Path object")
|
||||
|
||||
def test_open_file_using_str(data_path):
|
||||
# Check that we didn't mess up the string passing
|
||||
try:
|
||||
fname= f'{data_path}/beam_En700eV_-40deg_300V_10us_d0_f0_100.clust'
|
||||
r = ClusterFileReader(fname)
|
||||
assert r.read(10).size == 10 # Read to make sure file is really open
|
||||
except:
|
||||
pytest.fail("Could not open file using string")
|
||||
|
||||
def test_references_on_read(data_path):
|
||||
fname= (data_path/'beam_En700eV_-40deg_300V_10us_d0_f0_100.clust').as_posix()
|
||||
r = ClusterFileReader(fname)
|
||||
|
Reference in New Issue
Block a user