Skip to content

Commit

Permalink
Removed condition for file size on Windows (#1568)
Browse files Browse the repository at this point in the history
* Removed condition

* Disable autoclrf and removed is_unix check

* Enable test for windows for baseline checks

* Enable test for windows in test_stats.py

* Enable test for windows in test_describe.py

* Enable test for windows in commands>test_describe.py

* Enable test for windows in commands>test_describe.py

* Enable test for windows in commands>test_validate.py

* Enable test for windows
  • Loading branch information
shashigharti committed Jul 31, 2023
1 parent d6f2552 commit e62fd67
Show file tree
Hide file tree
Showing 13 changed files with 16 additions and 60 deletions.
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Don't apply EOL normalization for csv files
*.csv -text
*.txt -text
12 changes: 3 additions & 9 deletions tests/analyzer/test_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

import pytest

from frictionless import Package, platform

IS_UNIX = platform.type != "windows"
from frictionless import Package

pytestmark = pytest.mark.skipif(
sys.version_info < (3, 10),
Expand Down Expand Up @@ -122,11 +120,7 @@ def test_analyze_package_invalid_data():
}
package = Package(descriptor)
analysis = package.analyze()
assert (
round(analysis["capital-invalid"]["averageRecordSizeInBytes"]) == 12
if IS_UNIX
else 14
)
assert round(analysis["capital-invalid"]["averageRecordSizeInBytes"]) == 12
assert analysis["capital-invalid"]["fields"] == 4
assert analysis["capital-invalid"]["fieldStats"] == {}
assert analysis["capital-invalid"]["rows"] == 4
Expand Down Expand Up @@ -241,7 +235,7 @@ def test_analyze_package_detailed_invalid_data():
package = Package(descriptor)
analysis = package.analyze(detailed=True)
name = "capital-invalid"
assert round(analysis[name]["averageRecordSizeInBytes"]) == 12 if IS_UNIX else 14
assert round(analysis[name]["averageRecordSizeInBytes"]) == 12
assert analysis[name]["fields"] == 4
assert list(analysis[name]["fieldStats"].keys()) == [
"id",
Expand Down
11 changes: 4 additions & 7 deletions tests/analyzer/test_resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@

import pytest

from frictionless import platform
from frictionless.resources import TableResource

IS_UNIX = platform.type != "windows"

pytestmark = pytest.mark.skipif(
sys.version_info < (3, 10),
reason="Supported on Python3.10+",
Expand All @@ -32,7 +29,7 @@ def test_analyze_resource():
"fields",
"rows",
]
assert round(analysis["averageRecordSizeInBytes"]) == 85 if IS_UNIX else 86
assert round(analysis["averageRecordSizeInBytes"]) == 85
assert analysis["fields"] == 11
assert analysis["rows"] == 9
assert analysis["rowsWithNullValues"] == 2
Expand All @@ -57,7 +54,7 @@ def test_analyze_resource_detailed():
"fields",
"rows",
]
assert round(analysis["averageRecordSizeInBytes"]) == 85 if IS_UNIX else 86
assert round(analysis["averageRecordSizeInBytes"]) == 85
assert analysis["fields"] == 11
assert analysis["rows"] == 9
assert analysis["rowsWithNullValues"] == 2
Expand Down Expand Up @@ -225,7 +222,7 @@ def test_analyze_resource_detailed_with_empty_rows():
def test_analyze_resource_with_invalid_data():
resource = TableResource(path="data/invalid.csv")
analysis = resource.analyze()
assert round(analysis["averageRecordSizeInBytes"]) == 12 if IS_UNIX else 14
assert round(analysis["averageRecordSizeInBytes"]) == 12
assert analysis["fields"] == 4
assert analysis["fieldStats"] == {}
assert analysis["rows"] == 4
Expand All @@ -237,7 +234,7 @@ def test_analyze_resource_with_invalid_data():
def test_analyze_resource_detailed_with_invalid_data():
resource = TableResource(path="data/invalid.csv")
analysis = resource.analyze(detailed=True)
assert round(analysis["averageRecordSizeInBytes"]) == 12 if IS_UNIX else 14
assert round(analysis["averageRecordSizeInBytes"]) == 12
assert analysis["fields"] == 4
assert list(analysis["fieldStats"].keys()) == ["id", "name", "field3", "name2"]
assert analysis["rows"] == 4
Expand Down
10 changes: 1 addition & 9 deletions tests/checks/test_baseline.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import pytest

from frictionless import Resource, platform
from frictionless import Resource

# General

Expand Down Expand Up @@ -29,15 +27,13 @@ def test_validate_invalid():
# Stats


@pytest.mark.skipif(platform.type == "windows", reason="Fix on Windows")
def test_validate_baseline_stats_hash():
hash = "sha256:a1fd6c5ff3494f697874deeb07f69f8667e903dd94a7bc062dd57550cea26da8"
resource = Resource("data/table.csv", hash=hash)
report = resource.validate()
assert report.task.valid


@pytest.mark.skipif(platform.type == "windows", reason="Fix on Windows")
def test_validate_baseline_stats_hash_invalid():
hash = "6c2c61dd9b0e9c6876139a449ed87933"
resource = Resource("data/table.csv", hash="bad")
Expand All @@ -50,14 +46,12 @@ def test_validate_baseline_stats_hash_invalid():
]


@pytest.mark.skipif(platform.type == "windows", reason="Fix on Windows")
def test_validate_baseline_stats_bytes():
resource = Resource("data/table.csv", bytes=30)
report = resource.validate()
assert report.task.valid


@pytest.mark.skipif(platform.type == "windows", reason="Fix on Windows")
def test_validate_baseline_stats_bytes_invalid():
resource = Resource("data/table.csv", bytes=40)
report = resource.validate()
Expand All @@ -68,14 +62,12 @@ def test_validate_baseline_stats_bytes_invalid():
]


@pytest.mark.skipif(platform.type == "windows", reason="Fix on Windows")
def test_validate_baseline_stats_rows():
resource = Resource("data/table.csv", rows=2)
report = resource.validate()
assert report.task.valid


@pytest.mark.skipif(platform.type == "windows", reason="Fix on Windows")
def test_validate_baseline_stats_rows_invalid():
resource = Resource("data/table.csv", rows=3)
report = resource.validate()
Expand Down
1 change: 0 additions & 1 deletion tests/console/commands/test_describe.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
# General


@pytest.mark.skipif(platform.type == "windows", reason="Fix on Windows")
def test_console_describe():
actual = runner.invoke(console, "describe data/table.csv --stats --yaml")
assert actual.exit_code == 0
Expand Down
4 changes: 1 addition & 3 deletions tests/console/commands/test_validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import yaml
from typer.testing import CliRunner

from frictionless import Detector, Dialect, platform, validate
from frictionless import Detector, Dialect, validate
from frictionless.console import console

runner = CliRunner()
Expand Down Expand Up @@ -81,7 +81,6 @@ def test_console_validate_field_missing_values():
assert no_time(json.loads(actual.stdout)) == no_time(expect.to_descriptor())


@pytest.mark.skipif(platform.type == "windows", reason="Fix on Windows")
def test_console_validate_chucksum_hash():
actual = runner.invoke(
console,
Expand All @@ -95,7 +94,6 @@ def test_console_validate_chucksum_hash():
assert no_time(json.loads(actual.stdout)) == no_time(expect.to_descriptor())


@pytest.mark.skipif(platform.type == "windows", reason="Fix on Windows")
def test_console_validate_chucksum_bytes():
actual = runner.invoke(console, "validate data/table.csv --json --bytes 30")
expect = validate("data/table.csv", bytes=30)
Expand Down
1 change: 0 additions & 1 deletion tests/package/test_describe.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ def test_describe_package_basepath():
assert package.get_resource("chunk2").basepath == "data"


@pytest.mark.skipif(platform.type == "windows", reason="Fix on Windows")
def test_describe_package_hashing():
package = Package.describe("data/chunk*.csv", stats=True)
assert (
Expand Down
1 change: 0 additions & 1 deletion tests/resource/test_dereference.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
# General


@pytest.mark.skipif(platform.type == "windows", reason="Fix on Windows")
def test_resource_dereference():
resource = Resource(path="data/table.csv", schema="data/schema.json")
resource.infer(stats=True)
Expand Down
5 changes: 1 addition & 4 deletions tests/resource/test_describe.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import pytest

from frictionless import Detector, Dialect, Resource, formats, platform
from frictionless import Detector, Dialect, Resource, formats

# General

Expand All @@ -25,7 +23,6 @@ def test_resource_describe():
}


@pytest.mark.skipif(platform.type == "windows", reason="Fix on Windows")
def test_resource_describe_with_stats():
resource = Resource.describe("data/table.csv", stats=True)
assert isinstance(resource, Resource)
Expand Down
6 changes: 1 addition & 5 deletions tests/resource/test_infer.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import pytest

from frictionless import Resource, platform
from frictionless import Resource

# General


@pytest.mark.skipif(platform.type == "windows", reason="Fix on Windows")
def test_resource_infer():
resource = Resource(path="data/table.csv")
resource.infer(stats=True)
Expand All @@ -30,7 +27,6 @@ def test_resource_infer():
}


@pytest.mark.skipif(platform.type == "windows", reason="Fix on Windows")
def test_resource_infer_source_non_tabular():
resource = Resource(path="data/text.txt")
resource.infer(stats=True)
Expand Down
5 changes: 1 addition & 4 deletions tests/resource/test_read.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,23 @@

import pytest

from frictionless import Resource, platform, resources
from frictionless import Resource, resources

# General


@pytest.mark.skipif(platform.type == "windows", reason="Fix on Windows")
@pytest.mark.skipif(sys.version_info < (3, 7), reason="Requires Python3.7+")
def test_resource_read_bytes():
resource = Resource(path="data/text.txt")
bytes = resource.read_bytes()
assert bytes == b"text\n"


@pytest.mark.skipif(platform.type == "windows", reason="Fix on Windows")
def test_resource_read_bytes_bug_1341():
assert len(Resource("data/issue-1341.csv").read_bytes()) == 16792
assert len(Resource("data/issue-1066.csv").read_bytes()) == 3289808


@pytest.mark.skipif(platform.type == "windows", reason="Fix on Windows")
def test_resource_read_text():
resource = Resource(path="data/text.txt")
text = resource.read_text()
Expand Down
8 changes: 1 addition & 7 deletions tests/resources/table/test_stats.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pytest

from frictionless import Dialect, platform
from frictionless import Dialect
from frictionless.resources import TableResource

BASEURL = "https://raw.githubusercontent.com/frictionlessdata/frictionless-py/master/%s"
Expand All @@ -9,7 +9,6 @@
# General


@pytest.mark.skipif(platform.type == "windows", reason="Fix on Windows")
def test_resource_stats_hash():
with TableResource(path="data/doublequote.csv") as resource:
resource.read_rows()
Expand All @@ -19,7 +18,6 @@ def test_resource_stats_hash():
)


@pytest.mark.skipif(platform.type == "windows", reason="Fix on Windows")
def test_resource_stats_hash_compressed():
with TableResource(path="data/doublequote.csv.zip") as resource:
resource.read_rows()
Expand All @@ -30,7 +28,6 @@ def test_resource_stats_hash_compressed():


@pytest.mark.vcr
@pytest.mark.skipif(platform.type == "windows", reason="Fix on Windows")
def test_resource_stats_hash_remote():
with TableResource(path=BASEURL % "data/doublequote.csv") as resource:
resource.read_rows()
Expand All @@ -40,22 +37,19 @@ def test_resource_stats_hash_remote():
)


@pytest.mark.skipif(platform.type == "windows", reason="Fix on Windows")
def test_resource_stats_bytes():
with TableResource(path="data/doublequote.csv") as resource:
resource.read_rows()
assert resource.stats.bytes == 7346


@pytest.mark.skipif(platform.type == "windows", reason="Fix on Windows")
def test_resource_stats_bytes_compressed():
with TableResource(path="data/doublequote.csv.zip") as resource:
resource.read_rows()
assert resource.stats.bytes == 1265


@pytest.mark.vcr
@pytest.mark.skipif(platform.type == "windows", reason="Fix on Windows")
def test_resource_stats_bytes_remote():
with TableResource(path=BASEURL % "data/doublequote.csv") as resource:
resource.read_rows()
Expand Down
9 changes: 0 additions & 9 deletions tests/validator/resource/test_stats.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,15 @@
import pytest

from frictionless import platform
from frictionless.resources import TableResource

# General


@pytest.mark.skipif(platform.type == "windows", reason="Fix on Windows")
def test_resource_validate_stats_hash():
hash = "sha256:a1fd6c5ff3494f697874deeb07f69f8667e903dd94a7bc062dd57550cea26da8"
resource = TableResource(path="data/table.csv", hash=hash)
report = resource.validate()
assert report.task.valid


@pytest.mark.skipif(platform.type == "windows", reason="Fix on Windows")
def test_resource_validate_stats_hash_invalid():
hash = "6c2c61dd9b0e9c6876139a449ed87933"
resource = TableResource(path="data/table.csv", hash="bad")
Expand All @@ -27,14 +22,12 @@ def test_resource_validate_stats_hash_invalid():
]


@pytest.mark.skipif(platform.type == "windows", reason="Fix on Windows")
def test_resource_validate_stats_bytes():
resource = TableResource(path="data/table.csv", bytes=30)
report = resource.validate()
assert report.task.valid


@pytest.mark.skipif(platform.type == "windows", reason="Fix on Windows")
def test_resource_validate_stats_bytes_invalid():
resource = TableResource(path="data/table.csv", bytes=40)
report = resource.validate()
Expand All @@ -45,14 +38,12 @@ def test_resource_validate_stats_bytes_invalid():
]


@pytest.mark.skipif(platform.type == "windows", reason="Fix on Windows")
def test_resource_validate_stats_rows():
resource = TableResource(path="data/table.csv", rows=2)
report = resource.validate()
assert report.task.valid


@pytest.mark.skipif(platform.type == "windows", reason="Fix on Windows")
def test_resource_validate_stats_rows_invalid():
resource = TableResource(path="data/table.csv", rows=3)
report = resource.validate()
Expand Down

0 comments on commit e62fd67

Please sign in to comment.