Skip to content

TST: Added grid and cli test markers #741

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
markers =
slow: marks tests as slow (deselect with '-m "not slow"')
network: marks tests that need a network connection (deselect with '-m "not network"')
cli: marks tests that need the CLI installed (deselect with '-m "not cli"')
grid: marks tests that need transformation grids (deselect with '-m "not grid"')
1 change: 1 addition & 0 deletions test/crs/test_crs.py
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,7 @@ def test_coordinate_operation_grids():
)


@pytest.mark.grid
def test_coordinate_operation_grids__alternative_grid_name():
cc = CoordinateOperation.from_epsg(1312, True)
assert len(cc.grids) == 1
Expand Down
9 changes: 9 additions & 0 deletions test/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
)


@pytest.mark.cli
@PYPROJ_CLI_ENDPONTS
def test_main(input_command, tmpdir):
with tmp_chdir(str(tmpdir)):
Expand All @@ -29,6 +30,7 @@ def test_main(input_command, tmpdir):
assert "-v, --verbose Show verbose debugging version information." in output


@pytest.mark.cli
@PYPROJ_CLI_ENDPONTS
@pytest.mark.parametrize("option", ["-v", "--verbose"])
def test_main__verbose(input_command, option, tmpdir):
Expand All @@ -46,6 +48,7 @@ def test_main__verbose(input_command, option, tmpdir):
assert "-v, --verbose " not in output


@pytest.mark.cli
@PYPROJ_CLI_ENDPONTS
@pytest.mark.parametrize("option", [["-h"], []])
def test_sync(input_command, option, tmpdir):
Expand Down Expand Up @@ -74,6 +77,7 @@ def _check_list_files_header(lines):
assert lines[1].rstrip("\r") == "----------------------------------"


@pytest.mark.cli
@pytest.mark.network
@PYPROJ_CLI_ENDPONTS
def test_sync__source_id__list(input_command, tmpdir):
Expand All @@ -96,6 +100,7 @@ def test_sync__source_id__list(input_command, tmpdir):
assert "fr_ign" == line.split("|")[1].strip()


@pytest.mark.cli
@pytest.mark.network
@PYPROJ_CLI_ENDPONTS
def test_sync__area_of_use__list(input_command, tmpdir):
Expand All @@ -118,6 +123,7 @@ def test_sync__area_of_use__list(input_command, tmpdir):
assert "France" in line.split("|")[-1]


@pytest.mark.cli
@pytest.mark.network
@PYPROJ_CLI_ENDPONTS
def test_sync__file__list(input_command, tmpdir):
Expand All @@ -140,6 +146,7 @@ def test_sync__file__list(input_command, tmpdir):
assert "ntf_r93" in line.split("|")[0]


@pytest.mark.cli
@pytest.mark.network
@PYPROJ_CLI_ENDPONTS
def test_sync__bbox__list(input_command, tmpdir):
Expand All @@ -163,6 +170,7 @@ def test_sync__bbox__list(input_command, tmpdir):
assert " | fr_ign | " in output


@pytest.mark.cli
@pytest.mark.network
@PYPROJ_CLI_ENDPONTS
def test_sync__bbox__list__exclude_world_coverage(input_command, tmpdir):
Expand All @@ -187,6 +195,7 @@ def test_sync__bbox__list__exclude_world_coverage(input_command, tmpdir):
assert " | fr_ign | " in output


@pytest.mark.cli
@PYPROJ_CLI_ENDPONTS
@pytest.mark.parametrize(
"extra_arg",
Expand Down
1 change: 1 addition & 0 deletions test/test_datum.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from test.conftest import grids_available


@pytest.mark.grid
@pytest.mark.parametrize("proj_class", [Proj, CRS])
def test_datum(proj_class):
p1 = proj_class(proj="latlong", datum="WGS84")
Expand Down
11 changes: 11 additions & 0 deletions test/test_transformer.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def test_tranform_wgs84_to_custom():
assert f"{xx:.3f} {yy:.3f}" == "212.623 4604.975"


@pytest.mark.grid
def test_transform_wgs84_to_alaska():
with pytest.warns(FutureWarning):
lat_lon_proj = pyproj.Proj(init="epsg:4326", preserve_units=False)
Expand Down Expand Up @@ -497,6 +498,7 @@ def test_repr(from_crs, to_crs, expected_repr):
assert repr(Transformer.from_crs(from_crs, to_crs)) == expected_repr


@pytest.mark.grid
def test_repr__conditional():
trans_repr = repr(Transformer.from_crs(4326, 26917))
if grids_available(
Expand Down Expand Up @@ -608,6 +610,7 @@ def test_transformer_group():
assert trans_group.best_available


@pytest.mark.grid
def test_transformer_group__unavailable():
trans_group = TransformerGroup(4326, 2964)
for transformer in trans_group.transformers:
Expand Down Expand Up @@ -649,6 +652,7 @@ def test_transformer_group__unavailable():
assert not trans_group.best_available


@pytest.mark.grid
def test_transform_group__missing_best():
with pytest.warns(FutureWarning):
lat_lon_proj = pyproj.Proj(init="epsg:4326", preserve_units=False)
Expand All @@ -675,6 +679,7 @@ def test_transform_group__missing_best():
assert "ntv2_0" in trans_group.transformers[0].definition


@pytest.mark.grid
def test_transform_group__area_of_interest():
if not grids_available("ca_nrc_ntv2_0.tif"):
with pytest.warns(
Expand Down Expand Up @@ -707,6 +712,7 @@ def test_transform_group__area_of_interest():
)


@pytest.mark.grid
def test_transformer_group__get_transform_crs():
tg = TransformerGroup("epsg:4258", "epsg:7415")
if not grids_available("nl_nsgi_rdtrans2018.tif"):
Expand All @@ -715,6 +721,7 @@ def test_transformer_group__get_transform_crs():
assert len(tg.transformers) == 2


@pytest.mark.grid
def test_transformer__area_of_interest():
transformer = Transformer.from_crs(
4326, 2964, area_of_interest=AreaOfInterest(-136.46, 49.0, -60.72, 83.17)
Expand All @@ -729,6 +736,7 @@ def test_transformer__area_of_interest():
)


@pytest.mark.grid
def test_transformer_proj__area_of_interest():
transformer = Transformer.from_proj(
4326, 2964, area_of_interest=AreaOfInterest(-136.46, 49.0, -60.72, 83.17)
Expand Down Expand Up @@ -870,6 +878,7 @@ def test_transformer_group__network_enabled():
assert grid.available


@pytest.mark.grid
@patch.dict("os.environ", {"PROJ_NETWORK": "ON"}, clear=True)
def test_transformer_group__network_disabled():
with proj_network_env():
Expand Down Expand Up @@ -970,6 +979,7 @@ def test_transform_honours_input_types(x, y, z):
assert transformer.transform(xx=x, yy=y, zz=z) == (x, y, z)


@pytest.mark.grid
@pytest.mark.network
@patch("pyproj.transformer.get_user_data_dir")
def test_transformer_group__download_grids(get_user_data_dir_mock, tmp_path, capsys):
Expand Down Expand Up @@ -1016,6 +1026,7 @@ def test_transformer_group__download_grids(get_user_data_dir_mock, tmp_path, cap
download_mock.assert_not_called()


@pytest.mark.grid
@patch("pyproj.transformer._download_resource_file")
@patch("pyproj.transformer.get_user_data_dir")
def test_transformer_group__download_grids__directory(
Expand Down