Skip to content

Commit e54ef40

Browse files
[pre-commit.ci] auto fixes from pre-commit hooks
1 parent b1f6369 commit e54ef40

File tree

4 files changed

+26
-11
lines changed

4 files changed

+26
-11
lines changed

tests/conftest.py

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
import json
2-
from pathlib import Path
31
import importlib.resources
4-
import pytest
2+
import json
53
import logging
6-
74
from functools import lru_cache
5+
from pathlib import Path
6+
7+
import pytest
88

99
logger = logging.getLogger(__name__)
1010

11+
1112
@lru_cache()
1213
def has_sas():
1314
try:
@@ -17,36 +18,45 @@ def has_sas():
1718
except ImportError:
1819
return False
1920

21+
2022
# diffpy.structure
2123
@lru_cache()
2224
def has_diffpy_structure():
2325
_msg_nostructure = "No module named 'diffpy.structure'"
2426
try:
2527
import diffpy.structure as m
28+
2629
del m
2730
return True
2831
except ImportError:
2932
return False
30-
logger.warning("Cannot import diffpy.structure, Structure tests skipped.")
33+
logger.warning(
34+
"Cannot import diffpy.structure, Structure tests skipped."
35+
)
36+
3137

3238
@lru_cache()
3339
def has_pyobjcryst():
3440
_msg_nopyobjcryst = "No module named 'pyobjcryst'"
3541
try:
3642
import pyobjcryst as m
43+
3744
del m
3845
return True
3946
except ImportError:
4047
return False
4148
logger.warning("Cannot import pyobjcryst, pyobjcryst tests skipped.")
4249

50+
4351
# diffpy.srreal
4452

53+
4554
@lru_cache()
4655
def has_diffpy_srreal():
4756
_msg_nosrreal = "No module named 'diffpy.srreal'"
4857
try:
4958
import diffpy.srreal.pdfcalculator as m
59+
5060
del m
5161
return True
5262
except ImportError:
@@ -58,14 +68,17 @@ def has_diffpy_srreal():
5868
def sas_available():
5969
return has_sas()
6070

71+
6172
@pytest.fixture(scope="session")
6273
def diffpy_structure_available():
6374
return has_diffpy_structure()
6475

76+
6577
@pytest.fixture(scope="session")
6678
def diffpy_srreal_available():
6779
return has_diffpy_srreal()
6880

81+
6982
@pytest.fixture(scope="session")
7083
def pyobjcryst_available():
7184
return has_pyobjcryst()
@@ -89,6 +102,10 @@ def user_filesystem(tmp_path):
89102
@pytest.fixture
90103
def datafile():
91104
"""Fixture to load a test data file from the testdata package directory."""
105+
92106
def _datafile(filename):
93-
return importlib.resources.files("diffpy.srfit.tests.testdata").joinpath(filename)
107+
return importlib.resources.files(
108+
"diffpy.srfit.tests.testdata"
109+
).joinpath(filename)
110+
94111
return _datafile

tests/test_sas.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
##############################################################################
1515
"""Tests for sas package."""
1616

17-
import pytest
1817
import numpy
18+
import pytest
1919

2020
from diffpy.srfit.sas import SASGenerator, SASParser, SASProfile
2121
from diffpy.srfit.sas.sasimport import sasimport
@@ -24,6 +24,7 @@
2424
# FIXME: adjust sensitivity of the pytest.approx statements when ready to test
2525
# with sasview installed.
2626

27+
2728
def testParser(sas_available, datafile):
2829
if not sas_available:
2930
pytest.skip("sas package not available")
@@ -135,6 +136,7 @@ def test_generator(sas_available):
135136
assert 0 == pytest.approx(res)
136137
return
137138

139+
138140
def testGenerator2(sas_available, datafile):
139141
if not sas_available:
140142
pytest.skip("sas package not available")

tests/test_sgconstraints.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
import numpy
2020

21-
2221
# ----------------------------------------------------------------------------
2322

2423

tests/utils.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,8 @@
2020

2121
import diffpy.srfit.equation.literals as literals
2222
from diffpy.srfit.sas.sasimport import sasimport
23-
2423
from tests import logger
2524

26-
2725
# Helper functions for testing -----------------------------------------------
2826

2927

@@ -51,7 +49,6 @@ def noObserversInGlobalBuilders():
5149
return rv
5250

5351

54-
5552
def capturestdout(f, *args, **kwargs):
5653
"""Capture the standard output from a call of function f."""
5754
savestdout = sys.stdout

0 commit comments

Comments
 (0)