Skip to content
This repository has been archived by the owner on Dec 21, 2023. It is now read-only.

Commit

Permalink
Remove buggy unit test that has little value (#3086)
Browse files Browse the repository at this point in the history
  • Loading branch information
TobyRoseman authored Apr 2, 2020
1 parent bdcc1bd commit 75f27e8
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 100 deletions.
1 change: 0 additions & 1 deletion scripts/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ boto3==1.12.22

argparse>=1.2.1
pytest>=4.6.3
hypothesis>=4.50,<5.0
wheel>=0.29.0
six>=1.12.0
requests>=2.9.1
Expand Down
99 changes: 0 additions & 99 deletions src/python/turicreate/test/test_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

import array
import datetime
import hypothesis
import json # Python built-in JSON module
import math
import os
Expand Down Expand Up @@ -69,58 +68,6 @@ def __init__(self, url):


class JSONTest(unittest.TestCase):
# Only generate lists of dicts, but allow nearly-arbitrary JSON inside those.
# However, limit to length 1 to make sure the keys are the same in all rows.

# Known bug #1: escaped chars give different behavior in SFrame JSON parsing
# vs Python's built-in JSON module. Not sure which is correct:
"""
Original JSON: [{"": [{"\f": 0}]}]
Expected: +---------------+
| X1 |
+---------------+
| [{'\x0c': 0}] |
+---------------+
[1 rows x 1 columns]
Actual: +--------------+
| X1 |
+--------------+
| [{'\\f': 0}] |
+--------------+
[1 rows x 1 columns]
"""
# In the meantime, let's use `string.ascii_letters + string.digits` instead of
# `string.printable` (which contains the problematic characters).
hypothesis_json = hypothesis.strategies.lists(
hypothesis.strategies.dictionaries(
keys=hypothesis.strategies.text(string.ascii_letters + string.digits),
values=hypothesis.strategies.recursive(
# Known bug #2: [{"": null}] parses as "null" in SFrame, and should be None
# Once this is fixed, uncomment the line below.
# hypothesis.strategies.none() |
# Known bug #3: [{"": false}] parses as "false" in SFrame, and should be 0
# Once this is fixed, uncomment the line below.
# hypothesis.strategies.booleans() |
hypothesis.strategies.integers(
min_value=-(2 ** 53) + 1, max_value=(2 ** 53) - 1
)
| hypothesis.strategies.floats()
| hypothesis.strategies.text(string.ascii_letters + string.digits),
lambda children: hypothesis.strategies.lists(children, 1)
| hypothesis.strategies.dictionaries(
hypothesis.strategies.text(string.ascii_letters + string.digits),
children,
min_size=1,
),
),
min_size=1,
max_size=1,
),
min_size=1,
max_size=1,
)

def _assertEqual(self, x, y):
if type(x) in [long, int]:
self.assertTrue(type(y) in [long, int])
Expand Down Expand Up @@ -370,52 +317,6 @@ def test_strange_128_char_corner_case(self):
sf_expected = SFrame(df)
_SFrameComparer._assert_sframe_equal(sf_expected, sf_actual)

@pytest.mark.xfail(
reason="Non-deterministic test failure tracked in https://github.com/apple/turicreate/issues/2934"
)
# deterministic across runs, and may take a while
@hypothesis.settings(
derandomize=True, suppress_health_check=[hypothesis.HealthCheck.too_slow]
)
@hypothesis.given(hypothesis_json)
def test_arbitrary_json(self, json_obj):
# Known bug #1: escaped chars give different behavior in SFrame JSON parsing
# vs Python's built-in JSON module. Not sure which is correct.
# Workaround captured in definition of `hypothesis_json`

# Known bug #2: [{"": null}] parses as "null" in SFrame, and should be None
# Workaround captured in definition of `hypothesis_json`

# Known bug #3: [{"": false}] parses as "false" in SFrame, and should be 0
# Workaround captured in definition of `hypothesis_json`

try:
json_text = json.dumps(json_obj, allow_nan=False)
except:
# not actually valid JSON - skip this example
return

try:
expected = SFrame(json_obj).unpack("X1", column_name_prefix="")
except TypeError:
# something like TypeError: A common type cannot be infered from types integer, string.
# TC enforces all list items have the same type, which
# JSON does not necessarily enforce. Let's skip those examples.
return
with tempfile.NamedTemporaryFile("w") as f:
f.write(json_text)
f.flush()

try:
actual = SFrame.read_json(f.name)
except TypeError:
# something like TypeError: A common type cannot be infered from types integer, string.
# TC enforces all list items have the same type, which
# JSON does not necessarily enforce. Let's skip those examples.
return

_SFrameComparer._assert_sframe_equal(expected, actual)

def test_true_false_substitutions(self):
expecteda = [["a", "b", "c"], ["a", "b", "c"]]
expectedb = [["d", "false", "e", 0, "true", 1, "a"], ["d", "e", "f"]]
Expand Down

0 comments on commit 75f27e8

Please sign in to comment.