forked from conda/conda
-
Notifications
You must be signed in to change notification settings - Fork 0
/
conftest.py
55 lines (39 loc) · 1.39 KB
/
conftest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# -*- coding: utf-8 -*-
# Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
from functools import partial
import os
import sys
import warnings
import py
import pytest
from conda.common.compat import PY3
from conda.gateways.disk.create import TemporaryDirectory
from conda.core.subdir_data import SubdirData
win_default_shells = ["cmd.exe", "powershell", "git_bash", "cygwin"]
shells = ["bash", "zsh"]
if sys.platform == "win32":
shells = win_default_shells
def pytest_addoption(parser):
parser.addoption("--shell", action="append", default=[],
help="list of shells to run shell tests on")
def pytest_generate_tests(metafunc):
if 'shell' in metafunc.fixturenames:
metafunc.parametrize("shell", metafunc.config.option.shell)
@pytest.fixture(autouse=True)
def suppress_resource_warning():
'''
Suppress `Unclosed Socket Warning`
It seems urllib3 keeps a socket open to avoid costly recreation costs.
xref: https://github.com/kennethreitz/requests/issues/1882
'''
if PY3:
warnings.filterwarnings("ignore", category=ResourceWarning)
@pytest.fixture(scope='function')
def tmpdir(tmpdir, request):
tmpdir = TemporaryDirectory(dir=str(tmpdir))
request.addfinalizer(tmpdir.cleanup)
return py.path.local(tmpdir.name)
@pytest.fixture(autouse=True)
def clear_subdir_cache():
SubdirData.clear_cached_local_channel_data()