pytest.mark.timeout

Here are the examples of the python api pytest.mark.timeout taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

35 Examples 7

Example 1

Project: storjtorrent Source File: test_session.py
    @pytest.mark.timeout(5)
    def test_add_torrent_and_seed(self, session_with_torrent, capsys):
        assert len(session_with_torrent.handles) is 1
        while len(session_with_torrent._status['torrents']) is 0:
            pass
        assert session_with_torrent._status['torrents']['data']['state_str']\
            is 'seeding'
        out, err = capsys.readouterr()
        if not session_with_torrent.verbose:
            assert out == ''

Example 2

Project: python-mcollective Source File: test_symbols.py
    @pytest.mark.timeout(method='thread', timeout=15)
    def test_symbols(self):
        body = {
            ':agent': 'demo',
            ':action': 'mounts',
            ':caller': 'user=rafaduran',
            ':data': {':process_results': True},
        }
        msg = message.Message(body=body, agent='demo', config=self.config)
        simple_rpc = rpc.SimpleAction(msg=msg,
                                      agent='demo',
                                      action='mounts',
                                      config=self.config)
        result = simple_rpc.call(timeout=15)
        assert len(result) == 1
        res_msg = result[0]
        assert res_msg[':senderagent'] == 'demo'
        assert res_msg[':requestid'] == msg[':requestid']

Example 3

Project: storjtorrent Source File: test_session.py
    @pytest.mark.timeout(5)
    def test_add_torrent_and_download(self, default_session):
        default_session.add_torrent(REMOTE_TORRENT)
        assert len(default_session.handles) is 1
        while len(default_session._status['torrents']) is 0:
            pass
        assert default_session._status['torrents'].popitem()[1]['state_str']\
            == 'downloading metadata'

Example 4

Project: storjtorrent Source File: test_session.py
    @pytest.mark.timeout(5)
    def test_add_magnet_and_download(self, default_session):
        default_session.add_torrent(REMOTE_MAGNET)
        assert len(default_session.handles) is 1
        while len(default_session._status['torrents']) is 0:
            pass
        assert default_session._status['torrents'].popitem()[1]['state_str']\
            == 'downloading metadata'

Example 5

Project: storjtorrent Source File: test_session.py
Function: test_get_status
    @pytest.mark.timeout(5)
    def test_get_status(self, session_with_torrent):
        while 'data' not in session_with_torrent.get_status()['torrents']:
            pass
        assert session_with_torrent.get_status()[
            'torrents']['data']['state_str'] is 'seeding'

Example 6

Project: storjtorrent Source File: test_session.py
    @pytest.mark.timeout(10)
    def test_reannounce(self, session_with_torrent):
        session_with_torrent.reannounce()
        while 'm-search' not in ''.join(session_with_torrent
                                        ._status['alerts']):
            pass
        assert True

Example 7

Project: conda Source File: test_create.py
    @pytest.mark.timeout(300)
    def test_list_with_pip_egg(self):
        with make_temp_env("python=3 pip") as prefix:
            check_call(PYTHON_BINARY + " -m pip install --egg --no-binary flask flask==0.10.1",
                       cwd=prefix, shell=True)
            stdout, stderr = run_command(Commands.LIST, prefix)
            stdout_lines = stdout.split('\n')
            assert any(line.endswith("<pip>") for line in stdout_lines
                       if line.lower().startswith("flask"))

Example 8

Project: conda Source File: test_create.py
    @pytest.mark.timeout(300)
    def test_list_with_pip_wheel(self):
        with make_temp_env("python=3 pip") as prefix:
            check_call(PYTHON_BINARY + " -m pip install flask==0.10.1",
                       cwd=prefix, shell=True)
            stdout, stderr = run_command(Commands.LIST, prefix)
            stdout_lines = stdout.split('\n')
            assert any(line.endswith("<pip>") for line in stdout_lines
                       if line.lower().startswith("flask"))

            # regression test for #3433
            run_command(Commands.INSTALL, prefix, "python=3.4")
            assert_package_is_installed(prefix, 'python-3.4.')

Example 9

Project: conda Source File: test_create.py
    @pytest.mark.timeout(600)
    def test_install_python2_and_env_symlinks(self):
        with make_temp_env("python=2") as prefix:
            assert exists(join(prefix, PYTHON_BINARY))
            assert_package_is_installed(prefix, 'python-2')

            # test symlinks created with env
            print(os.listdir(join(prefix, BIN_DIRECTORY)))
            if on_win:
                assert isfile(join(prefix, BIN_DIRECTORY, 'activate'))
                assert isfile(join(prefix, BIN_DIRECTORY, 'deactivate'))
                assert isfile(join(prefix, BIN_DIRECTORY, 'conda'))
                assert isfile(join(prefix, BIN_DIRECTORY, 'activate.bat'))
                assert isfile(join(prefix, BIN_DIRECTORY, 'deactivate.bat'))
                assert isfile(join(prefix, BIN_DIRECTORY, 'conda.bat'))
            else:
                assert islink(join(prefix, BIN_DIRECTORY, 'activate'))
                assert islink(join(prefix, BIN_DIRECTORY, 'deactivate'))
                assert islink(join(prefix, BIN_DIRECTORY, 'conda'))

Example 10

Project: conda Source File: test_create.py
Function: test_remove_all
    @pytest.mark.timeout(300)
    def test_remove_all(self):
        with make_temp_env("python=2") as prefix:
            assert exists(join(prefix, PYTHON_BINARY))
            assert_package_is_installed(prefix, 'python-2')

            run_command(Commands.REMOVE, prefix, '--all')
            assert not exists(prefix)

Example 11

Project: conda Source File: test_create.py
    @pytest.mark.timeout(300)
    def test_install_prune(self):
        with make_temp_env("python=2 decorator") as prefix:
            assert_package_is_installed(prefix, 'decorator')

            # prune is a feature used by conda-env
            # conda itself does not provide a public API for it
            index = get_index_trap(prefix=prefix)
            actions = plan.install_actions(prefix,
                                           index,
                                           specs=['flask'],
                                           prune=True)
            plan.execute_actions(actions, index, verbose=True)

            assert_package_is_installed(prefix, 'flask')
            assert not package_is_installed(prefix, 'decorator')

Example 12

Project: conda Source File: test_create.py
    @pytest.mark.timeout(300)
    def test_clone_offline(self):
        with make_temp_env("python flask=0.10.1") as prefix:
            assert_package_is_installed(prefix, 'flask-0.10.1')
            assert_package_is_installed(prefix, 'python')

            with enforce_offline():
                with make_temp_env("--clone", prefix, "--offline") as clone_prefix:
                    assert_package_is_installed(clone_prefix, 'flask-0.10.1')
                    assert_package_is_installed(clone_prefix, 'python')

Example 13

Project: conda Source File: test_export.py
Function: test_basic
    @pytest.mark.timeout(900)
    def test_basic(self):
        with make_temp_env("python=3") as prefix:
            assert exists(join(prefix, PYTHON_BINARY))
            assert_package_is_installed(prefix, 'python-3')

            output, error = run_command(Commands.LIST, prefix, "-e")

            with tempfile.NamedTemporaryFile(mode="w", suffix="txt", delete=False) as env_txt:
                env_txt.write(output)
                env_txt.flush()
                env_txt.close()
                prefix2 = make_temp_prefix()
                run_command(Commands.CREATE, prefix2 , "--file " + env_txt.name)

                assert_package_is_installed(prefix2, "python")

            output2, error= run_command(Commands.LIST, prefix2, "-e")
            self.assertEqual(output, output2)

Example 14

Project: audiolazy Source File: test_itertools.py
  @pytest.mark.timeout(2)
  def test_star_with_endless_generator_input(self):
    def gen(): # Yields [], [1], [2, 2], [3, 3, 3], ...
      for c in count():
        yield [c] * c
    expected = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6]
    result = chain.star(gen())
    assert isinstance(result, Stream)
    assert result.take(len(expected)) == expected

Example 15

Project: pyethereum Source File: test_contracts.py
Function: test_sort
@pytest.mark.timeout(100)
def test_sort():
    s = tester.state()
    c = s.abi_contract(sort_code)
    assert c.sort([9]) == [9]
    assert c.sort([9, 5]) == [5, 9]
    assert c.sort([9, 3, 5]) == [3, 5, 9]
    assert c.sort([80, 234, 112, 112, 29]) == [29, 80, 112, 112, 234]

Example 16

Project: pyethereum Source File: test_contracts.py
@pytest.mark.timeout(100)
def test_indirect_sort():
    s = tester.state()
    open(filename9, 'w').write(sort_code)
    c = s.abi_contract(sort_tester_code)
    os.remove(filename9)
    assert c.test([80, 234, 112, 112, 29]) == [29, 80, 112, 112, 234]

Example 17

Project: pyethereum Source File: test_contracts.py
@pytest.mark.timeout(100)
def test_prevhashes():
    s = tester.state()
    c = s.abi_contract(prevhashes_code)
    s.mine(7)
    # Hashes of last 14 blocks including existing one
    o1 = [x % 2 ** 256 for x in c.get_prevhashes(14)]
    # hash of self = 0, hash of blocks back to genesis block as is, hash of
    # blocks before genesis block = 0
    t1 = [0] + [utils.big_endian_to_int(b.hash) for b in s.blocks[-2::-1]] \
        + [0] * 6
    assert o1 == t1
    s.mine(256)
    # Test 256 limit: only 1 <= g <= 256 generation ancestors get hashes shown
    o2 = [x % 2 ** 256 for x in c.get_prevhashes(270)]
    t2 = [0] + [utils.big_endian_to_int(b.hash) for b in s.blocks[-2:-258:-1]] \
        + [0] * 13
    assert o2 == t2

Example 18

Project: ansible-container Source File: test_slow.py
@pytest.mark.timeout(240)
def test_build_minimal_docker_container():
    env = ScriptTestEnvironment()
    result = env.run('ansible-container', 'build', '--flatten', cwd=project_dir('minimal'), expect_stderr=True)
    assert "Aborting on container exit" in result.stdout
    assert "Exported minimal-minimal with image ID " in result.stderr

Example 19

Project: ansible-container Source File: test_slow.py
@pytest.mark.timeout(240)
def test_stop_minimal_docker_container():
    env = ScriptTestEnvironment()
    env.run('ansible-container', 'build', '--flatten',
            cwd=project_dir('minimal_sleep'), expect_stderr=True)
    env.run('ansible-container', 'run', '--detached', cwd=project_dir('minimal_sleep'), expect_stderr=True)
    result = env.run('ansible-container', 'stop', cwd=project_dir('minimal_sleep'), expect_stderr=True)
    assert "Stopping ansible_minimal1_1 ... done" in result.stderr
    assert "Stopping ansible_minimal2_1 ... done" in result.stderr

Example 20

Project: ansible-container Source File: test_slow.py
@pytest.mark.timeout(240)
def test_setting_ansible_container_envar():
    env = ScriptTestEnvironment()
    result = env.run('ansible-container', '--debug', 'build',
                     cwd=project_dir('environment'), expect_stderr=True)
    assert "web MYVAR=foo ANSIBLE_CONTAINER=1" in result.stdout
    assert "db MYVAR=foo ANSIBLE_CONTAINER=1" in result.stdout
    assert "mw ANSIBLE_CONTAINER=1" in result.stdout

Example 21

Project: osbrain Source File: test_timer.py
@pytest.mark.timeout(1)
def test_repeat_non_blocking():
    """
    A repeated action (i.e. timer) should always be executed in a separate
    thread, even the first execution.
    """
    def foo(x):
        time.sleep(x)

    timer = repeat(1., foo, 2.)
    timer.stop()

Example 22

Project: Growler Source File: test_http_parser.py
@pytest.mark.timeout(3)
@pytest.mark.parametrize("req_pieces, expected_header", [
    ((b"GET / HTTP/1.1\r\n", b'h:d\r\n\r\n'),
     {'H': 'd'}),

    ((b"GET / ", b"HTTP/1.1\r\n", b'x:y\r\n\r\n'),
     {'X': 'y'}),

    ((b"GET / HTTP/1.1\r\n", b'h:d', b"\r\nhost: now", b"here.com\r\n\r\n"),
     {'HOST': 'nowhere.com', 'H': 'd'}),

    ((b"GET / HTTP/1.1\n", b'h:d', b'\n', b'\ta b\n', b"x:y\n\n"),
     {'X': 'y', 'H': ['d', 'a b']}),

    ((b"GET / HTTP/1.1\n", b'h:d\n', b"host: nowhere.com\n\n"),
     {'HOST': 'nowhere.com', 'H': 'd'}),

    ((b"GET / HTTP/1.1\n", b'A:B\n', b"host: nowhere.com", b"\n\n"),
     {'HOST': 'nowhere.com', 'A': 'B'}),

    ((b"GET / HTTP/1.1\r", b"\nh", b"OsT:  nowhere.com\r", b"\n\r\n"),
     {'HOST': 'nowhere.com'}),
])
def test_good_header_pieces(parser, req_pieces, expected_header):

    for piece in req_pieces:
        parser.consume(piece)

    assert parser.headers == expected_header

Example 23

Project: raiden Source File: test_service.py
@pytest.mark.timeout(3)
@pytest.mark.parametrize('blockchain_type', ['mock'])
@pytest.mark.parametrize('number_of_nodes', [2])
@pytest.mark.parametrize('transport_class', [UnreliableTransport])
def test_ping_unreachable(raiden_network):
    app0, app1 = raiden_network  # pylint: disable=unbalanced-tuple-unpacking

    UnreliableTransport.droprate = 1  # drop everything to force disabling of re-sends
    RaidenProtocol.try_interval = 0.1  # for fast tests
    RaidenProtocol.repeat_messages = True

    messages = setup_messages_cb()
    UnreliableTransport.network.counter = 0

    ping = Ping(nonce=0)
    app0.raiden.sign(ping)
    app0.raiden.protocol.send_and_wait(app1.raiden.address, ping)
    gevent.sleep(2)

    assert len(messages) == 5  # 5 dropped Pings
    for i, message in enumerate(messages):
        assert decode(message) == ping

    RaidenProtocol.repeat_messages = False

Example 24

Project: storjtorrent Source File: test_storjtorrent.py
Function: test_get_status
    @pytest.mark.timeout(5)
    def test_get_status(self, st_with_torrent):
        while 'data' not in st_with_torrent.get_status()['torrents']:
            pass
        assert True

Example 25

Project: coala Source File: LocalBearTestHelper.py
def verify_local_bear(bear,
                      valid_files,
                      invalid_files,
                      filename=None,
                      settings={},
                      force_linebreaks=True,
                      create_tempfile=True,
                      timeout=None,
                      tempfile_kwargs={}):
    """
    Generates a test for a local bear by checking the given valid and invalid
    file contents. Simply use it on your module level like:

    YourTestName = verify_local_bear(YourBear, (['valid line'],),
                                     (['invalid line'],))

    :param bear:             The Bear class to test.
    :param valid_files:      An iterable of files as a string list that won't
                             yield results.
    :param invalid_files:    An iterable of files as a string list that must
                             yield results.
    :param filename:         The filename to use for valid and invalid files.
    :param settings:         A dictionary of keys and values (both string) from
                             which settings will be created that will be made
                             available for the tested bear.
    :param force_linebreaks: Whether to append newlines at each line
                             if needed. (Bears expect a \\n for every line)
    :param create_tempfile:  Whether to save lines in tempfile if needed.
    :param timeout:          The total time to run the test for.
    :param tempfile_kwargs:  Kwargs passed to tempfile.mkstemp() if tempfile
                             needs to be created.
    :return:                 A unittest.TestCase object.
    """
    @pytest.mark.timeout(timeout)
    @generate_skip_decorator(bear)
    class LocalBearTest(LocalBearTestHelper):

        def setUp(self):
            self.section = Section('name')
            self.uut = bear(self.section,
                            queue.Queue())
            for name, value in settings.items():
                self.section.append(Setting(name, value))

        def test_valid_files(self):
            self.assertIsInstance(valid_files, (list, tuple))
            for file in valid_files:
                self.check_validity(self.uut,
                                    file.splitlines(keepends=True),
                                    filename,
                                    valid=True,
                                    force_linebreaks=force_linebreaks,
                                    create_tempfile=create_tempfile,
                                    tempfile_kwargs=tempfile_kwargs)

        def test_invalid_files(self):
            self.assertIsInstance(invalid_files, (list, tuple))
            for file in invalid_files:
                self.check_validity(self.uut,
                                    file.splitlines(keepends=True),
                                    filename,
                                    valid=False,
                                    force_linebreaks=force_linebreaks,
                                    create_tempfile=create_tempfile,
                                    tempfile_kwargs=tempfile_kwargs)

    return LocalBearTest

Example 26

Project: conda Source File: test_cli.py
Function: test_search
    @pytest.mark.timeout(300)
    def test_search(self):
        with captured():
            res = capture_json_with_argv('conda search --json')
        self.assertIsInstance(res, dict)
        self.assertIsInstance(res['conda'], list)
        self.assertIsInstance(res['conda'][0], dict)
        keys = ('build', 'channel', 'extracted', 'features', 'fn',
                'installed', 'version')
        for key in keys:
            self.assertIn(key, res['conda'][0])

        stdout, stderr, rc = run_inprocess_conda_command('conda search * --json')
        assert json.loads(stdout.strip())['exception_name'] == 'CommandArgumentError'
        assert stderr == ''
        assert rc > 0

        res = capture_json_with_argv('conda search --canonical --json')
        self.assertIsInstance(res, list)
        self.assertIsInstance(res[0], text_type)

Example 27

Project: conda Source File: test_create.py
    @pytest.mark.timeout(900)
    def test_create_install_update_remove(self):
        with make_temp_env("python=3") as prefix:
            assert exists(join(prefix, PYTHON_BINARY))
            assert_package_is_installed(prefix, 'python-3')

            run_command(Commands.INSTALL, prefix, 'flask=0.10')
            assert_package_is_installed(prefix, 'flask-0.10.1')
            assert_package_is_installed(prefix, 'python-3')

            # Test force reinstall
            run_command(Commands.INSTALL, prefix, '--force', 'flask=0.10')
            assert_package_is_installed(prefix, 'flask-0.10.1')
            assert_package_is_installed(prefix, 'python-3')

            run_command(Commands.UPDATE, prefix, 'flask')
            assert not package_is_installed(prefix, 'flask-0.10.1')
            assert_package_is_installed(prefix, 'flask')
            assert_package_is_installed(prefix, 'python-3')

            run_command(Commands.REMOVE, prefix, 'flask')
            assert not package_is_installed(prefix, 'flask-0.')
            assert_package_is_installed(prefix, 'python-3')

            run_command(Commands.INSTALL, prefix, '--revision 0')
            assert not package_is_installed(prefix, 'flask')
            assert_package_is_installed(prefix, 'python-3')

            self.assertRaises(CondaError, run_command, Commands.INSTALL, prefix, 'conda')
            assert not package_is_installed(prefix, 'conda')

            self.assertRaises(CondaError, run_command, Commands.INSTALL, prefix, 'constructor=1.0')
            assert not package_is_installed(prefix, 'constructor')

Example 28

Project: conda Source File: test_create.py
    @pytest.mark.timeout(300)
    def test_create_empty_env(self):
        with make_temp_env() as prefix:
            assert exists(join(prefix, BIN_DIRECTORY))
            assert exists(join(prefix, 'conda-meta/history'))

            list_output = run_command(Commands.LIST, prefix)
            stdout = list_output[0]
            stderr = list_output[1]
            expected_output = """# packages in environment at %s:
#

""" % prefix
            self.assertEqual(stdout, expected_output)
            self.assertEqual(stderr, '')

            revision_output = run_command(Commands.LIST, prefix, '--revisions')
            stdout = revision_output[0]
            stderr = revision_output[1]
            self.assertEquals(stderr, '')
            self.assertIsInstance(stdout, str)

Example 29

Project: conda Source File: test_create.py
    @pytest.mark.timeout(300)
    def test_install_tarball_from_local_channel(self):
        with make_temp_env("python flask=0.10.1") as prefix:
            assert_package_is_installed(prefix, 'flask-0.10.1')
            flask_data = [p for p in itervalues(linked_data(prefix)) if p['name'] == 'flask'][0]
            run_command(Commands.REMOVE, prefix, 'flask')
            assert not package_is_installed(prefix, 'flask-0.10.1')
            assert_package_is_installed(prefix, 'python')

            flask_fname = flask_data['fn']
            tar_old_path = join(context.pkgs_dirs[0], flask_fname)

            # Regression test for #2812
            # install from local channel
            for field in ('url', 'channel', 'schannel'):
                del flask_data[field]
            repodata = {'info': {}, 'packages': {flask_fname: flask_data}}
            with make_temp_env() as channel:
                subchan = join(channel, context.subdir)
                channel = path_to_url(channel)
                os.makedirs(subchan)
                tar_new_path = join(subchan, flask_fname)
                copyfile(tar_old_path, tar_new_path)
                with bz2.BZ2File(join(subchan, 'repodata.json.bz2'), 'w') as f:
                    f.write(json.dumps(repodata, cls=EntityEncoder).encode('utf-8'))
                run_command(Commands.INSTALL, prefix, '-c', channel, 'flask', '--json')
                assert_package_is_installed(prefix, channel + '::' + 'flask-')

                run_command(Commands.REMOVE, prefix, 'flask')
                assert not package_is_installed(prefix, 'flask-0')

                # Regression test for 2970
                # install from build channel as a tarball
                conda_bld = join(sys.prefix, 'conda-bld')
                conda_bld_sub = join(conda_bld, context.subdir)
                if not isdir(conda_bld_sub):
                    os.makedirs(conda_bld_sub)
                tar_bld_path = join(conda_bld_sub, flask_fname)
                copyfile(tar_new_path, tar_bld_path)
                # CondaFileNotFoundError: '/home/travis/virtualenv/python2.7.9/conda-bld/linux-64/flask-0.10.1-py27_2.tar.bz2'.
                run_command(Commands.INSTALL, prefix, tar_bld_path)
                assert_package_is_installed(prefix, 'flask-')

Example 30

Project: conda Source File: test_create.py
    @pytest.mark.timeout(300)
    def test_tarball_install_and_bad_metadata(self):
        with make_temp_env("python flask=0.10.1 --json") as prefix:
            assert_package_is_installed(prefix, 'flask-0.10.1')
            flask_data = [p for p in itervalues(linked_data(prefix)) if p['name'] == 'flask'][0]
            run_command(Commands.REMOVE, prefix, 'flask')
            assert not package_is_installed(prefix, 'flask-0.10.1')
            assert_package_is_installed(prefix, 'python')

            flask_fname = flask_data['fn']
            tar_old_path = join(context.pkgs_dirs[0], flask_fname)

            # regression test for #2886 (part 1 of 2)
            # install tarball from package cache, default channel
            run_command(Commands.INSTALL, prefix, tar_old_path)
            assert_package_is_installed(prefix, 'flask-0.')

            # regression test for #2626
            # install tarball with full path, outside channel
            tar_new_path = join(prefix, flask_fname)
            copyfile(tar_old_path, tar_new_path)
            run_command(Commands.INSTALL, prefix, tar_new_path)
            assert_package_is_installed(prefix, 'flask-0')

            # regression test for #2626
            # install tarball with relative path, outside channel
            run_command(Commands.REMOVE, prefix, 'flask')
            assert not package_is_installed(prefix, 'flask-0.10.1')
            tar_new_path = relpath(tar_new_path)
            run_command(Commands.INSTALL, prefix, tar_new_path)
            assert_package_is_installed(prefix, 'flask-0.')

            # regression test for #2886 (part 2 of 2)
            # install tarball from package cache, local channel
            run_command(Commands.REMOVE, prefix, 'flask', '--json')
            assert not package_is_installed(prefix, 'flask-0')
            run_command(Commands.INSTALL, prefix, tar_old_path)
            # The last install was from the `local::` channel
            assert_package_is_installed(prefix, 'flask-')

            # regression test for #2599
            linked_data_.clear()
            flask_metadata = glob(join(prefix, 'conda-meta', flask_fname[:-8] + '.json'))[-1]
            bad_metadata = join(prefix, 'conda-meta', 'flask.json')
            copyfile(flask_metadata, bad_metadata)
            assert not package_is_installed(prefix, 'flask', exact=True)
            assert_package_is_installed(prefix, 'flask-0.')

Example 31

Project: conda Source File: test_create.py
    @pytest.mark.timeout(600)
    def test_python2_pandas(self):
        with make_temp_env("python=2 pandas") as prefix:
            assert exists(join(prefix, PYTHON_BINARY))
            assert_package_is_installed(prefix, 'numpy')

Example 32

Project: conda Source File: test_create.py
    @pytest.mark.timeout(30)
    def test_bad_anaconda_token_infinite_loop(self):
        # First, confirm we get a 401 UNAUTHORIZED response from anaconda.org
        response = requests.get("https://conda.anaconda.org/t/cqgccfm1mfma/data-portal/"
                                "%s/repodata.json" % context.subdir)
        assert response.status_code == 401

        try:
            prefix = make_temp_prefix(str(uuid4())[:7])
            channel_url = "https://conda.anaconda.org/t/cqgccfm1mfma/data-portal"
            run_command(Commands.CONFIG, prefix, "--add channels %s" % channel_url)
            stdout, stderr = run_command(Commands.CONFIG, prefix, "--show")
            yml_obj = yaml_load(stdout)
            assert yml_obj['channels'] == [channel_url, 'defaults']

            with pytest.raises(CondaHTTPError):
                run_command(Commands.SEARCH, prefix, "boltons", "--json")

            stdout, stderr = run_command(Commands.SEARCH, prefix, "boltons", "--json",
                                         use_exception_handler=True)
            json_obj = json.loads(stdout)
            assert json_obj['status_code'] == 401

        finally:
            rmtree(prefix, ignore_errors=True)
            reset_context()

Example 33

Project: conda Source File: test_priority.py
    @pytest.mark.timeout(300)
    def test_channel_order_channel_priority_true(self):
        with make_temp_env("python=3 pycosat==0.6.1") as prefix:
            assert_package_is_installed(prefix, 'python')
            assert_package_is_installed(prefix, 'pycosat')

            # add conda-forge channel
            o, e = run_command(Commands.CONFIG, prefix, "--prepend channels conda-forge", '--json')

            assert context.channels == ("conda-forge", "defaults"), o + e
            # update --all
            update_stdout, _ = run_command(Commands.UPDATE, prefix, '--all')

            # pycosat should be in the SUPERCEDED list
            superceded_split = update_stdout.split('SUPERCEDED')
            assert len(superceded_split) == 2
            assert 'pycosat' in superceded_split[1]

            # python sys.version should show conda-forge python
            python_tuple = get_conda_list_tuple(prefix, "python")
            assert python_tuple[3] == 'conda-forge'
            # conda list should show pycosat coming from conda-forge
            pycosat_tuple = get_conda_list_tuple(prefix, "pycosat")
            assert pycosat_tuple[3] == 'conda-forge'

Example 34

Project: conda Source File: test_priority.py
    @pytest.mark.timeout(300)
    def test_channel_priority_update(self):
        """
            This case will fail now
        """
        with make_temp_env("python=3 ") as prefix:
            assert_package_is_installed(prefix, 'python')

            # add conda-forge channel
            o, e = run_command(Commands.CONFIG, prefix, "--prepend channels conda-forge", '--json')
            assert context.channels == ("conda-forge", "defaults"), o+e

            # update python
            update_stdout, _ = run_command(Commands.UPDATE, prefix, 'python')

            # pycosat should be in the SUPERCEDED list
            superceded_split = update_stdout.split('UPDATED')
            assert len(superceded_split) == 2
            assert 'conda-forge' in superceded_split[1]

            # python sys.version should show conda-forge python
            python_tuple = get_conda_list_tuple(prefix, "python")
            assert python_tuple[3] == 'conda-forge'

Example 35

Project: audiolazy Source File: test_io.py
@p("data", [orange(25), white_noise(100) + 3.])
@pytest.mark.timeout(2)
def test_output_only(monkeypatch, data):
  monkeypatch.setattr(pyaudio, "PyAudio", MockPyAudio)
  monkeypatch.setattr(pyaudio, "Stream", MockStream)
  monkeypatch.setattr(_portaudio, "write_stream", mock_write_stream)

  chunk_size = 16
  data = list(data)
  with AudioIO(True) as player:
    player.play(data, chunk_size=chunk_size)

    played_data = list(player._pa.fake_output)
    ld, lpd = len(data), len(played_data)
    assert all(isinstance(x, float) for x in played_data)
    assert lpd % chunk_size == 0
    assert lpd - ld == -ld % chunk_size
    assert all(x == 0. for x in played_data[ld - lpd:]) # Zero-pad at end
    assert almost_eq(played_data, data) # Data loss (64-32bits conversion)

  assert player._pa.terminated # Test whether "terminate" was called