Skip to content

Commit

Permalink
TST: don't rely on exact order in listdir tests (#1193)
Browse files Browse the repository at this point in the history
  • Loading branch information
jorisvandenbossche authored and sgillies committed Feb 9, 2023
1 parent 9004181 commit bc32d5e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
1 change: 1 addition & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ All issue numbers are relative to https://github.com/Toblerity/Fiona/issues.
1.9.1 (TBD)
-----------

- Avoid dependence on listdir order in tests (#1193).
- Prevent empty geometries arrays from appearing in __geo_interface__ (#).
- setuptools added to pyproject.toml. Its pkg_resources module is used by the
CLI (#1191).
Expand Down
21 changes: 9 additions & 12 deletions tests/test_listing.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
"""Test listing a datasource's layers."""

import logging
import sys
import os

import pytest
Expand Down Expand Up @@ -77,7 +75,12 @@ def test_listing_pathobj(path_coutwildrnp_json):

def test_listdir_path(path_coutwildrnp_zip):
"""List directories in a path"""
assert fiona.listdir(f'zip://{path_coutwildrnp_zip}') == ['coutwildrnp.shp', 'coutwildrnp.shx', 'coutwildrnp.dbf', 'coutwildrnp.prj']
assert sorted(fiona.listdir("zip://{}".format(path_coutwildrnp_zip))) == [
"coutwildrnp.dbf",
"coutwildrnp.prj",
"coutwildrnp.shp",
"coutwildrnp.shx",
]


def test_listdir_path_not_existing(data_dir):
Expand All @@ -93,12 +96,6 @@ def test_listdir_invalid_path():
assert fiona.listdir(1)


def test_listdir_file(path_coutwildrnp_zip):
""" Test list directories of a file"""
with pytest.raises(FionaValueError):
fiona.listdir(f'zip://{path_coutwildrnp_zip}/coutwildrnp.shp')


def test_listdir_file(path_coutwildrnp_zip):
"""Test list directories of a file"""
with pytest.raises(FionaValueError):
Expand All @@ -109,9 +106,9 @@ def test_listdir_zipmemoryfile(bytes_coutwildrnp_zip):
"""Test list directories of a zipped memory file."""
with ZipMemoryFile(bytes_coutwildrnp_zip) as memfile:
print(memfile.name)
assert fiona.listdir(memfile.name) == [
"coutwildrnp.shp",
"coutwildrnp.shx",
assert sorted(fiona.listdir(memfile.name)) == [
"coutwildrnp.dbf",
"coutwildrnp.prj",
"coutwildrnp.shp",
"coutwildrnp.shx",
]

0 comments on commit bc32d5e

Please sign in to comment.