Skip to content

Commit 5fa2104

Browse files
Irliriona-r-j
andauthored
Exclude Test Scripts and Data from PyPI Release (#148)
* move tests to dir and rewrite paths * add python 3.7 test run support * add importlib_resources to appveyor * format files with 79 line length * run tests from root dir in workflow * docs: update changelog --------- Co-authored-by: Arian Jamasb <[email protected]>
1 parent 3e26557 commit 5fa2104

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+354
-229
lines changed

.appveyor.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ install:
1414
- conda config --set always_yes yes --set changeps1 no
1515
- conda update -q conda
1616
- conda info -a
17-
- conda create -q -n test-environment --channel=conda-forge mmtf-python numpy scipy pandas pytest looseversion python=%PYTHON_VERSION%
17+
- conda create -q -n test-environment --channel=conda-forge mmtf-python numpy scipy pandas pytest looseversion importlib_resources python=%PYTHON_VERSION%
1818
- activate test-environment
1919

2020
test_script:

.github/workflows/publish.yaml

+22-22
Original file line numberDiff line numberDiff line change
@@ -5,50 +5,50 @@ name: Publish BioPandas to PyPI / GitHub
55

66
on:
77
pull_request:
8-
branches: [ main ]
8+
branches: [main]
99

1010
jobs:
1111
test-style:
1212
name: Run style tests
1313
runs-on: ubuntu-latest
1414

1515
steps:
16-
- uses: actions/checkout@v3
16+
- uses: actions/checkout@v3
1717

18-
- name: Set up Python
19-
uses: actions/setup-python@v4
20-
with:
21-
python-version: '3.x'
22-
cache: 'pip'
18+
- name: Set up Python
19+
uses: actions/setup-python@v4
20+
with:
21+
python-version: "3.x"
22+
cache: "pip"
2323

24-
- name: Install package dependencies for testing
25-
run: pip install .[test]
24+
- name: Install package dependencies for testing
25+
run: pip install .[test]
2626

27-
- name: Run all the pytest tests
28-
run: flake8 ./biopandas
27+
- name: Run all the pytest tests
28+
run: flake8 ./biopandas
2929

3030
test-pytest:
3131
name: Run pytest tests
3232
runs-on: ubuntu-latest
3333

3434
steps:
35-
- uses: actions/checkout@v3
35+
- uses: actions/checkout@v3
3636

37-
- name: Set up Python
38-
uses: actions/setup-python@v4
39-
with:
40-
python-version: '3.x'
41-
cache: 'pip'
37+
- name: Set up Python
38+
uses: actions/setup-python@v4
39+
with:
40+
python-version: "3.x"
41+
cache: "pip"
4242

43-
- name: Install package dependencies for testing
44-
run: pip install .[test]
43+
- name: Install package dependencies for testing
44+
run: pip install .[test]
4545

46-
- name: Run all the pytest tests
47-
run: pytest ./biopandas -sv
46+
- name: Run all the pytest tests
47+
run: pytest -sv
4848

4949
build-n-publish:
5050
needs: [test-pytest] # only runs if tests are passing
51-
if: startsWith(github.ref, 'refs/tags/v') # Check if the tag starts with 'v'
51+
if: startsWith(github.ref, 'refs/tags/v') # Check if the tag starts with 'v'
5252
name: Build and publish to PyPI
5353
runs-on: ubuntu-latest
5454

docs/CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ The CHANGELOG for the current development version is available at
88

99
- Feature: added method to `PandasMmcif` that allow to select by model ids. PR #[145](https://github.com/BioPandas/biopandas/pull/145))
1010
- Dev: switched testing framework entirely to pytest. Drops nose dependency due to version conflicts with Python 3.12 (`nose`) and 3.8 (`nose`) PR #[146](https://github.com/BioPandas/biopandas/pull/146))
11+
- Avoid inclusion of test scripts and test data in the PyPI release of the Biopandas library. PR #[148](https://github.com/BioPandas/biopandas/pull/148). Addresses issue [#147](https://github.com/BioPandas/biopandas/issues/147)
1112

1213

1314
### 0.5.0dev1 (31/7/2023)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

biopandas/mmcif/tests/test_amino3to1.py tests/mmcif/test_amino3to1.py

+14-7
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,23 @@
44
# Project Website: http://rasbt.github.io/biopandas/
55
# Code Repository: https://github.com/rasbt/biopandas
66

7-
import os
7+
import sys
8+
9+
if sys.version_info >= (3, 9):
10+
import importlib.resources as pkg_resources
11+
else:
12+
import importlib_resources as pkg_resources
813

914
import numpy as np
15+
16+
import tests.mmcif.data
1017
from biopandas.mmcif import PandasMmcif
1118

19+
TEST_DATA = pkg_resources.files(tests.mmcif.data)
20+
1221

1322
def test_defaults():
14-
TESTDATA_1t48 = os.path.join(os.path.dirname(__file__), "data", "1t48.cif")
23+
TESTDATA_1t48 = str(TEST_DATA.joinpath("1t48.cif"))
1524
p1t48 = PandasMmcif()
1625
p1t48.read_mmcif(TESTDATA_1t48)
1726
expect_res = [
@@ -309,7 +318,7 @@ def test_defaults():
309318

310319

311320
def test_sameindex():
312-
TESTDATA_1t48 = os.path.join(os.path.dirname(__file__), "data", "1t48.cif")
321+
TESTDATA_1t48 = str(TEST_DATA.joinpath("1t48.cif"))
313322
p1t48 = PandasMmcif()
314323
p1t48.read_mmcif(TESTDATA_1t48)
315324
p1t48.df["ATOM"].index = np.zeros(p1t48.df["ATOM"].shape[0], dtype=int)
@@ -608,9 +617,7 @@ def test_sameindex():
608617

609618

610619
def test_multichain():
611-
TESTDATA_5mtn = os.path.join(
612-
os.path.dirname(__file__), "data", "5mtn_multichain.cif"
613-
)
620+
TESTDATA_5mtn = str(TEST_DATA.joinpath("5mtn_multichain.cif"))
614621
mtn = PandasMmcif()
615622
mtn.read_mmcif(TESTDATA_5mtn)
616623
expect_res_a = [
@@ -818,7 +825,7 @@ def test_multichain():
818825

819826

820827
def test_pdb_with_insertion_codes():
821-
PDB_2D7T_PATH = os.path.join(os.path.dirname(__file__), "data", "2d7t.cif")
828+
PDB_2D7T_PATH = str(TEST_DATA.joinpath("2d7t.cif"))
822829

823830
ppdb = PandasMmcif().read_mmcif(PDB_2D7T_PATH)
824831
sequence = ppdb.amino3to1()

biopandas/mmcif/tests/test_assign_df.py tests/mmcif/test_assign_df.py

+10-4
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,22 @@
44
# Project Website: http://rasbt.github.io/biopandas/
55
# Code Repository: https://github.com/rasbt/biopandas
66

7-
import os
7+
import sys
88

9+
if sys.version_info >= (3, 9):
10+
import importlib.resources as pkg_resources
11+
else:
12+
import importlib_resources as pkg_resources
13+
14+
import tests.mmcif.data
915
from biopandas.mmcif import PandasMmcif
10-
from biopandas.testutils import assert_raises
16+
from tests.testutils import assert_raises
1117

12-
TESTDATA_FILENAME = os.path.join(os.path.dirname(__file__), "data", "3eiy.cif")
18+
TEST_DATA = pkg_resources.files(tests.mmcif.data)
1319

1420

1521
def test_overwrite_df():
16-
data_path = os.path.join(os.path.dirname(__file__), "data", "3eiy.cif")
22+
data_path = str(TEST_DATA.joinpath("3eiy.cif"))
1723
pdb = PandasMmcif().read_mmcif(data_path)
1824

1925
def overwrite():

biopandas/mmcif/tests/test_distance.py tests/mmcif/test_distance.py

+13-4
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,23 @@
44
# Project Website: http://rasbt.github.io/biopandas/
55
# Code Repository: https://github.com/rasbt/biopandas
66

7-
import os
7+
import sys
8+
9+
if sys.version_info >= (3, 9):
10+
import importlib.resources as pkg_resources
11+
else:
12+
import importlib_resources as pkg_resources
813

914
import pandas as pd
15+
16+
import tests.mmcif.data
1017
from biopandas.mmcif import PandasMmcif
1118

19+
TEST_DATA = pkg_resources.files(tests.mmcif.data)
20+
1221

1322
def test_equal():
14-
TESTDATA_1t48 = os.path.join(os.path.dirname(__file__), "data", "1t48.cif")
23+
TESTDATA_1t48 = str(TEST_DATA.joinpath("1t48.cif"))
1524

1625
p1t48 = PandasMmcif()
1726
p1t48.read_mmcif(TESTDATA_1t48)
@@ -25,7 +34,7 @@ def test_equal():
2534

2635

2736
def test_deprecated_str_arg():
28-
TESTDATA_1t48 = os.path.join(os.path.dirname(__file__), "data", "1t48.cif")
37+
TESTDATA_1t48 = str(TEST_DATA.joinpath("1t48.cif"))
2938

3039
p1t48 = PandasMmcif()
3140
p1t48.read_mmcif(TESTDATA_1t48)
@@ -39,7 +48,7 @@ def test_deprecated_str_arg():
3948

4049

4150
def test_use_external_df():
42-
TESTDATA_1t48 = os.path.join(os.path.dirname(__file__), "data", "1t48.cif")
51+
TESTDATA_1t48 = str(TEST_DATA.joinpath("1t48.cif"))
4352

4453
p1t48 = PandasMmcif()
4554
p1t48.read_mmcif(TESTDATA_1t48)

biopandas/mmcif/tests/test_multiple_models.py tests/mmcif/test_multiple_models.py

+20-4
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,43 @@
44
# License: BSD 3 clause
55
# Project Website: http://rasbt.github.io/biopandas/
66
# Code Repository: https://github.com/rasbt/biopandas
7-
import os
7+
import sys
88

9+
if sys.version_info >= (3, 9):
10+
import importlib.resources as pkg_resources
11+
else:
12+
import importlib_resources as pkg_resources
13+
14+
import tests.mmcif.data
915
from biopandas.mmcif import PandasMmcif
1016

11-
TESTDATA_FILENAME = os.path.join(os.path.dirname(__file__), "data", "2jyf.cif.gz")
17+
TEST_DATA = pkg_resources.files(tests.mmcif.data)
18+
19+
TESTDATA_FILENAME = str(TEST_DATA.joinpath("2jyf.cif.gz"))
20+
1221

1322
def test_label_models():
1423
biopandas_structure = PandasMmcif().read_mmcif(TESTDATA_FILENAME)
1524
biopandas_structure.label_models()
1625
assert "model_id" in biopandas_structure.df["ATOM"].columns
1726

27+
1828
def test_get_model():
1929
biopandas_structure = PandasMmcif().read_mmcif(TESTDATA_FILENAME)
2030
MODEL_INDEX = 1
2131
new_biopandas_structure = biopandas_structure.get_model(MODEL_INDEX)
22-
assert new_biopandas_structure.df["ATOM"]["pdbx_PDB_model_num"].all() == MODEL_INDEX
32+
assert (
33+
new_biopandas_structure.df["ATOM"]["pdbx_PDB_model_num"].all()
34+
== MODEL_INDEX
35+
)
2336

2437

2538
def test_get_models():
2639
biopandas_structure = PandasMmcif().read_mmcif(TESTDATA_FILENAME)
2740
MODEL_INDICES = [1, 3, 5]
2841

2942
new_biopandas_structure = biopandas_structure.get_models(MODEL_INDICES)
30-
assert new_biopandas_structure.df["ATOM"]["pdbx_PDB_model_num"].all() in MODEL_INDICES
43+
assert (
44+
new_biopandas_structure.df["ATOM"]["pdbx_PDB_model_num"].all()
45+
in MODEL_INDICES
46+
)

biopandas/mmcif/tests/test_read_mmcif.py tests/mmcif/test_read_mmcif.py

+19-20
Original file line numberDiff line numberDiff line change
@@ -5,36 +5,35 @@
55
# Code Repository: https://github.com/rasbt/biopandas
66

77

8-
import os
8+
import sys
9+
10+
if sys.version_info >= (3, 9):
11+
import importlib.resources as pkg_resources
12+
else:
13+
import importlib_resources as pkg_resources
914
from pathlib import Path
1015
from urllib.error import HTTPError
1116

1217
import pandas as pd
1318
import pytest
19+
from pandas.testing import assert_frame_equal
20+
21+
import tests.mmcif.data
1422
from biopandas.mmcif import PandasMmcif
1523
from biopandas.pdb import PandasPdb
16-
from biopandas.testutils import assert_raises
17-
from pandas.testing import assert_frame_equal
24+
from tests.testutils import assert_raises
25+
26+
TEST_DATA = pkg_resources.files(tests.mmcif.data)
1827

19-
TESTDATA_FILENAME = os.path.join(os.path.dirname(__file__), "data", "3eiy.cif")
28+
TESTDATA_FILENAME = str(TEST_DATA.joinpath("3eiy.cif"))
2029

2130
# Not clear on how ANISOU records are handled in mmCIF files so skipping
22-
# TESTDATA_FILENAME2 = os.path.join(
23-
# os.path.dirname(__file__), "data", "4eiy_anisouchunk.cif"
24-
# )
25-
TESTDATA_FILENAME2 = os.path.join(
26-
os.path.dirname(__file__), "data", "4eiy.cif"
27-
)
28-
TESTDATA_FILENAME_GZ = os.path.join(
29-
os.path.dirname(__file__), "data", "3eiy.cif.gz"
30-
)
31-
32-
TESTDATA_FILENAME_AF2_V4 = os.path.join(
33-
os.path.dirname(__file__), "data", "AF-Q5VSL9-F1-model_v4.cif"
34-
)
35-
TESTDATA_FILENAME_AF2_V3 = os.path.join(
36-
os.path.dirname(__file__), "data", "AF-Q5VSL9-F1-model_v3.cif"
37-
)
31+
# TESTDATA_FILENAME2 = str(TEST_DATA.joinpath("4eiy_anisouchunk.cif"))
32+
TESTDATA_FILENAME2 = str(TEST_DATA.joinpath("4eiy.cif"))
33+
TESTDATA_FILENAME_GZ = str(TEST_DATA.joinpath("3eiy.cif.gz"))
34+
35+
TESTDATA_FILENAME_AF2_V4 = str(TEST_DATA.joinpath("AF-Q5VSL9-F1-model_v4.cif"))
36+
TESTDATA_FILENAME_AF2_V3 = str(TEST_DATA.joinpath("AF-Q5VSL9-F1-model_v3.cif"))
3837

3938
ATOM_DF_COLUMNS = [
4039
"B_iso_or_equiv",

biopandas/mmcif/tests/test_rmsd.py tests/mmcif/test_rmsd.py

+15-6
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,26 @@
44
# Project Website: http://rasbt.github.io/biopandas/
55
# Code Repository: https://github.com/rasbt/biopandas
66

7-
import os
7+
import sys
8+
9+
if sys.version_info >= (3, 9):
10+
import importlib.resources as pkg_resources
11+
else:
12+
import importlib_resources as pkg_resources
813

914
import pytest
15+
16+
import tests.mmcif.data
1017
from biopandas.mmcif import PandasMmcif
1118

12-
TESTDATA_1t48 = os.path.join(os.path.dirname(__file__), "data", "1t48.cif")
13-
TESTDATA_1t49 = os.path.join(os.path.dirname(__file__), "data", "1t49.cif")
14-
# TESTDATA_lig1 = os.path.join(os.path.dirname(__file__), "data", "lig_conf_1.pdb")
15-
# TESTDATA_lig2 = os.path.join(os.path.dirname(__file__), "data", "lig_conf_2.pdb")
19+
TEST_DATA = pkg_resources.files(tests.mmcif.data)
20+
21+
TESTDATA_1t48 = str(TEST_DATA.joinpath("1t48.cif"))
22+
TESTDATA_1t49 = str(TEST_DATA.joinpath("1t49.cif"))
23+
# TESTDATA_lig1 = str(TEST_DATA.joinpath("lig_conf_1.pdb"))
24+
# TESTDATA_lig2 = str(TEST_DATA.joinpath("lig_conf_2.pdb"))
1625

17-
TESTDATA_rna = os.path.join(os.path.dirname(__file__), "data", "1ehz.cif")
26+
TESTDATA_rna = str(TEST_DATA.joinpath("1ehz.cif"))
1827

1928
p1t48 = PandasMmcif()
2029
p1t48.read_mmcif(TESTDATA_1t48)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)