Skip to content

Commit

Permalink
TST: use a fixed seed to have the same uniques across python versions
Browse files Browse the repository at this point in the history
TST: add pytest-mock to handle mocker fixture
  • Loading branch information
jreback committed Feb 16, 2019
1 parent 29008f5 commit 5e29b10
Show file tree
Hide file tree
Showing 15 changed files with 21 additions and 5 deletions.
1 change: 1 addition & 0 deletions ci/deps/azure-27-compat.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ dependencies:
# universal
- pytest
- pytest-xdist
- pytest-mock
- pip:
- html5lib==1.0b2
- beautifulsoup4==4.2.1
Expand Down
1 change: 1 addition & 0 deletions ci/deps/azure-27-locale.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ dependencies:
# universal
- pytest
- pytest-xdist
- pytest-mock
- hypothesis>=3.58.0
- pip:
- html5lib==1.0b2
Expand Down
1 change: 1 addition & 0 deletions ci/deps/azure-36-locale_slow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ dependencies:
# universal
- pytest
- pytest-xdist
- pytest-mock
- moto
- pip:
- hypothesis>=3.58.0
1 change: 1 addition & 0 deletions ci/deps/azure-37-locale.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ dependencies:
# universal
- pytest
- pytest-xdist
- pytest-mock
- pip:
- hypothesis>=3.58.0
- moto # latest moto in conda-forge fails with 3.7, move to conda dependencies when this is fixed
1 change: 1 addition & 0 deletions ci/deps/azure-37-numpydev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ dependencies:
# universal
- pytest
- pytest-xdist
- pytest-mock
- hypothesis>=3.58.0
- pip:
- "git+git://github.com/dateutil/dateutil.git"
Expand Down
1 change: 1 addition & 0 deletions ci/deps/azure-macos-35.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ dependencies:
# universal
- pytest
- pytest-xdist
- pytest-mock
- pip:
- python-dateutil==2.5.3
- hypothesis>=3.58.0
1 change: 1 addition & 0 deletions ci/deps/azure-windows-27.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,6 @@ dependencies:
- cython>=0.28.2
- pytest
- pytest-xdist
- pytest-mock
- moto
- hypothesis>=3.58.0
1 change: 1 addition & 0 deletions ci/deps/azure-windows-36.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@ dependencies:
- cython>=0.28.2
- pytest
- pytest-xdist
- pytest-mock
- hypothesis>=3.58.0
1 change: 1 addition & 0 deletions ci/deps/travis-27.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ dependencies:
# universal
- pytest
- pytest-xdist
- pytest-mock
- moto==1.3.4
- hypothesis>=3.58.0
- pip:
Expand Down
1 change: 1 addition & 0 deletions ci/deps/travis-36-locale.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ dependencies:
# universal
- pytest
- pytest-xdist
- pytest-mock
- moto
- pip:
- hypothesis>=3.58.0
1 change: 1 addition & 0 deletions ci/deps/travis-36-slow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,6 @@ dependencies:
# universal
- pytest
- pytest-xdist
- pytest-mock
- moto
- hypothesis>=3.58.0
1 change: 1 addition & 0 deletions ci/deps/travis-36.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ dependencies:
- pytest
- pytest-xdist
- pytest-cov
- pytest-mock
- hypothesis>=3.58.0
- pip:
- brotlipy
Expand Down
1 change: 1 addition & 0 deletions ci/deps/travis-37.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ dependencies:
- pytz
- pytest
- pytest-xdist
- pytest-mock
- hypothesis>=3.58.0
- s3fs
- pip:
Expand Down
5 changes: 2 additions & 3 deletions pandas/tests/io/formats/test_console.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,12 @@ def test_detect_console_encoding_fallback_to_default(monkeypatch, std, locale):


@pytest.mark.parametrize("size", ['', ['']])
def test_terminal_unknown_dimensions(monkeypatch, size):
mock = pytest.importorskip("unittest.mock")
def test_terminal_unknown_dimensions(monkeypatch, size, mocker):

def communicate(*args, **kwargs):
return size

monkeypatch.setattr('subprocess.Popen', mock.Mock())
monkeypatch.setattr('subprocess.Popen', mocker.Mock())
monkeypatch.setattr('subprocess.Popen.return_value.returncode', None)
monkeypatch.setattr(
'subprocess.Popen.return_value.communicate', communicate)
Expand Down
8 changes: 6 additions & 2 deletions pandas/tests/resample/test_datetime_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -1160,9 +1160,13 @@ def test_resample_nunique_with_date_gap():
@pytest.mark.parametrize('k', [10, 100, 1000])
def test_resample_group_info(n, k):
# GH10914

# use a fixed seed to always have the same uniques
prng = np.random.RandomState(1234)

dr = date_range(start='2015-08-27', periods=n // 10, freq='T')
ts = Series(np.random.randint(0, n // k, n).astype('int64'),
index=np.random.choice(dr, n))
ts = Series(prng.randint(0, n // k, n).astype('int64'),
index=prng.choice(dr, n))

left = ts.resample('30T').nunique()
ix = date_range(start=ts.index.min(), end=ts.index.max(),
Expand Down

0 comments on commit 5e29b10

Please sign in to comment.