From 4716bcf0fc741a7b67563048c612aa592d98d1fc Mon Sep 17 00:00:00 2001 From: Alexander Steppke Date: Mon, 3 Apr 2023 15:50:11 +0200 Subject: [PATCH] fixed more tests --- src/cristallina/utils.py | 2 +- tests/test_utils.py | 16 +++++++--------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/cristallina/utils.py b/src/cristallina/utils.py index a131060..d2a85da 100644 --- a/src/cristallina/utils.py +++ b/src/cristallina/utils.py @@ -23,7 +23,7 @@ def scan_info(run_number, base_path=None, small_data=True): sd_path_for_step=heuristic_extract_smalldata_path()+'run'+str(run_number).zfill(4)+'/acq'+str(i+1).zfill(4)+'.smalldata.h5' scan.info['scan_files'][i].append(sd_path_for_step) except KeyError: - logger.warn("Failed to load smalldata.") + logger.warning("Failed to load smalldata.") return scan diff --git a/tests/test_utils.py b/tests/test_utils.py index 7551aa5..3306fd6 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -3,18 +3,15 @@ import os import numpy as np from cristallina.utils import ROI, print_run_info, heuristic_extract_pgroup, gauss, find_nearest, xray_transmission -__author__ = "Alexander Steppke" def test_print(capsys): # this currently works only if the heuristic p-group extraction works # TODO: fix this shortcoming and use base_path throughout - os.chdir("/sf/cristallina/data/p19739/") - print_run_info(247) + print_run_info(185, base_path="tests/data/p20841/raw/") captured = capsys.readouterr() - assert "15453208940" in captured.out - assert "LiTbF4_rocking" in captured.out - + assert "17259343145" in captured.out + assert "scan_parameters" in captured.out def test_ROI(): @@ -26,8 +23,9 @@ def test_ROI(): def test_extract_pgroup(): - os.chdir("/sf/cristallina/data/p19739") - assert heuristic_extract_pgroup() == '19739' + os.chdir("tests/data/p20841/raw/") + assert heuristic_extract_pgroup() == '20841' + def test_gauss(): # Test a random Gauss value and check whether the value didn't change in time @@ -39,7 +37,7 @@ def test_find_nearest(): assert find_nearest(a,10.1) == 10 def test_xray_transmission(): - T = xray_transmission(9000,100e-6,material='Si') + T = xray_transmission(9000, 100e-6, material = 'Si') assert T == 0.342385039732607