Skip to content

Commit

Permalink
Removed pytest dependency from arcticdb (#1350)
Browse files Browse the repository at this point in the history
* moved param_dict code from arcticdb/util/test.py to
python/tests/util/mark.py
* removed xfail arg and if clause (if was not used and broken - it
appended a tuple to a list)
* updated the only use case: test_normalization.py

---------

Co-authored-by: Nick Clarke <[email protected]>
  • Loading branch information
DrNickClarke and Nick Clarke authored Feb 26, 2024
1 parent a18feca commit 6cb54b6
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 20 deletions.
2 changes: 1 addition & 1 deletion environment_unix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ dependencies:
- numpy
- pandas
- attrs
- pytest
- boto3
- werkzeug
- moto
Expand All @@ -80,3 +79,4 @@ dependencies:
- pyarrow
- asv
- pymongo
- pytest
18 changes: 0 additions & 18 deletions python/arcticdb/util/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,10 @@
from typing import Mapping, Any, Optional, Iterable, NamedTuple, List, AnyStr
import numpy as np
import pandas as pd
import pytest
import string
import random
import time
import attr
from copy import deepcopy
from functools import wraps

from arcticdb.config import Defaults
Expand Down Expand Up @@ -128,22 +126,6 @@ def config_context(name, value):
unset_config_int(name)


def param_dict(fields, cases=None, xfail=None):
_cases = deepcopy(cases) if cases else dict()
if _cases:
ids, params = zip(*list(sorted(_cases.items())))
else:
ids, params = [], []

if xfail is not None:
xfail_ids, xfail_params = zip(*list(sorted(xfail.items())))
xfail_marker = tuple(pytest.mark.xfail()(p) for p in xfail_params)
params = params + xfail_marker
ids = ids + xfail_ids

return pytest.mark.parametrize(fields, params, ids=ids)


CustomThing = NamedTuple(
"CustomThing",
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
)
from arcticdb.version_store._common import TimeFrame
from arcticdb.util.test import (
param_dict,
CustomThing,
TestCustomNormalizer,
assert_frame_equal,
Expand All @@ -46,6 +45,8 @@
from arcticdb.util._versions import IS_PANDAS_ZERO, IS_PANDAS_TWO
from arcticdb.exceptions import ArcticNativeException

from tests.util.mark import param_dict

params = {
"simple_dict": {"a": "1", "b": 2, "c": 3.0, "d": True},
"pd_ts": {"a": pd.Timestamp("2018-01-12 09:15"), "b": pd.Timestamp("2017-01-31", tz="America/New_York")},
Expand Down
12 changes: 12 additions & 0 deletions python/tests/util/mark.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
from typing import Union
from datetime import date
from numpy import datetime64
from copy import deepcopy


# TODO: Some tests are either segfaulting or failing on MacOS with conda builds.
# This is meant to be used as a temporary flag to skip/xfail those tests.
Expand Down Expand Up @@ -60,3 +62,13 @@ def until(until_date: Union[datetime64, date, str], mark_decorator):
```
"""
return mark_decorator if datetime64("today") <= datetime64(until_date) else _no_op_decorator


def param_dict(fields, cases=None):
_cases = deepcopy(cases) if cases else dict()
if _cases:
ids, params = zip(*list(sorted(_cases.items())))
else:
ids, params = [], []

return pytest.mark.parametrize(fields, params, ids=ids)

0 comments on commit 6cb54b6

Please sign in to comment.