Skip to content

Commit 5012731

Browse files
committed
diffpy and tests directories
1 parent dd57b34 commit 5012731

8 files changed

Lines changed: 156 additions & 0 deletions

File tree

diffpy/__init__.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/usr/bin/env python
2+
##############################################################################
3+
#
4+
# (c) 2024 The Trustees of Columbia University in the City of New York.
5+
# All rights reserved.
6+
#
7+
# File coded by: Billinge Group members and community contributors.
8+
#
9+
# See GitHub contributions for a more detailed list of contributors.
10+
# https://github.com/diffpy/diffpy.fourigui/graphs/contributors
11+
#
12+
# See LICENSE.rst for license information.
13+
#
14+
##############################################################################
15+
16+
"""Blank namespace package for module diffpy."""
17+
18+
19+
from pkgutil import extend_path
20+
21+
__path__ = extend_path(__path__, __name__)
22+
23+
# End of file

diffpy/fourigui/__init__.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/usr/bin/env python
2+
##############################################################################
3+
#
4+
# (c) 2024 The Trustees of Columbia University in the City of New York.
5+
# All rights reserved.
6+
#
7+
# File coded by: Billinge Group members and community contributors.
8+
#
9+
# See GitHub contributions for a more detailed list of contributors.
10+
# https://github.com/diffpy/diffpy.fourigui/graphs/contributors
11+
#
12+
# See LICENSE.rst for license information.
13+
#
14+
##############################################################################
15+
16+
"""Tool for visualizing 3D diffraction and PDF Images."""
17+
18+
# package version
19+
from diffpy.fourigui.version import __version__
20+
21+
# silence the pyflakes syntax checker
22+
assert __version__ or True
23+
24+
# End of file

diffpy/fourigui/tests/__init__.py

Whitespace-only changes.

diffpy/fourigui/tests/conftest.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import json
2+
from pathlib import Path
3+
4+
import pytest
5+
6+
7+
@pytest.fixture
8+
def user_filesystem(tmp_path):
9+
base_dir = Path(tmp_path)
10+
home_dir = base_dir / "home_dir"
11+
home_dir.mkdir(parents=True, exist_ok=True)
12+
cwd_dir = base_dir / "cwd_dir"
13+
cwd_dir.mkdir(parents=True, exist_ok=True)
14+
15+
home_config_data = {"username": "home_username", "email": "home@email.com"}
16+
with open(home_dir / "diffpyconfig.json", "w") as f:
17+
json.dump(home_config_data, f)
18+
19+
yield tmp_path

diffpy/fourigui/tests/debug.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/usr/bin/env python
2+
##############################################################################
3+
#
4+
# (c) 2024 The Trustees of Columbia University in the City of New York.
5+
# All rights reserved.
6+
#
7+
# File coded by: Billinge Group members and community contributors.
8+
#
9+
# See GitHub contributions for a more detailed list of contributors.
10+
# https://github.com/diffpy/diffpy.fourigui/graphs/contributors
11+
#
12+
# See LICENSE.rst for license information.
13+
#
14+
##############################################################################
15+
16+
"""
17+
Convenience module for debugging the unit tests using
18+
19+
python -m diffpy.fourigui.tests.debug
20+
21+
Exceptions raised by failed tests or other errors are not caught.
22+
"""
23+
24+
25+
if __name__ == "__main__":
26+
import sys
27+
28+
from diffpy.fourigui.tests import testsuite
29+
30+
pattern = sys.argv[1] if len(sys.argv) > 1 else ""
31+
suite = testsuite(pattern)
32+
suite.debug()
33+
34+
35+
# End of file

diffpy/fourigui/version.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/usr/bin/env python
2+
##############################################################################
3+
#
4+
# (c) 2024 The Trustees of Columbia University in the City of New York.
5+
# All rights reserved.
6+
#
7+
# File coded by: Billinge Group members and community contributors.
8+
#
9+
# See GitHub contributions for a more detailed list of contributors.
10+
# https://github.com/diffpy/diffpy.fourigui/graphs/contributors
11+
#
12+
# See LICENSE.rst for license information.
13+
#
14+
##############################################################################
15+
16+
"""Definition of __version__."""
17+
18+
# We do not use the other three variables, but can be added back if needed.
19+
# __all__ = ["__date__", "__git_commit__", "__timestamp__", "__version__"]
20+
21+
# obtain version information
22+
from importlib.metadata import version
23+
24+
__version__ = version("diffpy.fourigui")
25+
26+
# End of file

tests/conftest.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import json
2+
from pathlib import Path
3+
4+
import pytest
5+
6+
7+
@pytest.fixture
8+
def user_filesystem(tmp_path):
9+
base_dir = Path(tmp_path)
10+
home_dir = base_dir / "home_dir"
11+
home_dir.mkdir(parents=True, exist_ok=True)
12+
cwd_dir = base_dir / "cwd_dir"
13+
cwd_dir.mkdir(parents=True, exist_ok=True)
14+
15+
home_config_data = {"username": "home_username", "email": "home@email.com"}
16+
with open(home_dir / "diffpyconfig.json", "w") as f:
17+
json.dump(home_config_data, f)
18+
19+
yield tmp_path

tests/test_version.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
"""Unit tests for __version__.py
2+
"""
3+
4+
import diffpy.fourigui
5+
6+
7+
def test_package_version():
8+
"""Ensure the package version is defined and not set to the initial placeholder."""
9+
assert hasattr(diffpy.fourigui, "__version__")
10+
assert diffpy.fourigui.__version__ != "0.0.0"

0 commit comments

Comments
 (0)