Ejemplo n.º 1
0
def test_python_discovery_plugin_scan_invalid():
    """Test that the discovery plugin doesn't find non-python files."""
    pydp = PythonDiscoveryPlugin()
    package = Package(
        'invalid_package',
        os.path.join(os.path.dirname(__file__), 'invalid_package'))
    pydp.scan(package, 'level')
    assert not package['python_src']
Ejemplo n.º 2
0
def test_python_discovery_plugin_scan_valid():
    """Test that the Python discovery plugin finds valid python files."""
    pydp = PythonDiscoveryPlugin()
    package = Package(
        "valid_package", os.path.join(os.path.dirname(__file__), "valid_package")
    )
    pydp.scan(package, "level")
    expected = ["test.py", os.path.join("ignore_this", "ignoreme.py")]
    if pydp.file_command_exists():
        expected += ["oddextensionpy.source"]
    # We have to add the path to each of the above...yuck
    expected_fullpath = [os.path.join(package.path, filename) for filename in expected]
    # Neat trick to verify that two unordered lists are the same
    assert set(package["python_src"]) == set(expected_fullpath)
Ejemplo n.º 3
0
def test_python_discovery_plugin_scan_valid():
    """Test that the Python discovery plugin finds valid python files."""
    pydp = PythonDiscoveryPlugin()
    package = Package('valid_package',
                      os.path.join(os.path.dirname(__file__), 'valid_package'))
    pydp.scan(package, 'level')
    expected = ['test.py']
    if pydp.file_command_exists():
        expected += ['oddextensionpy.source']
    # We have to add the path to each of the above...yuck
    expected_fullpath = [
        os.path.join(package.path, filename) for filename in expected
    ]
    # Neat trick to verify that two unordered lists are the same
    assert set(package['python_src']) == set(expected_fullpath)
Ejemplo n.º 4
0
def test_python_discovery_plugin_scan_exceptions():
    """Test that the python discovery plugin properly respects exceptions."""
    pydp = PythonDiscoveryPlugin()
    package = Package('valid_package',
                      os.path.join(os.path.dirname(__file__), 'valid_package'))
    exceptions = Exceptions(
        os.path.join(os.path.dirname(__file__), 'exceptions.yaml'))
    pydp.scan(package, 'level', exceptions)
    expected_src = ['test.py', 'oddextensionpy.source']
    # We have to add the path to each of the above...yuck
    expected_src_fullpath = [
        os.path.join(package.path, filename) for filename in expected_src
    ]
    # Neat trick to verify that two unordered lists are the same
    assert set(package['python_src']) == set(expected_src_fullpath)
Ejemplo n.º 5
0
def test_python_discovery_plugin_scan_exceptions():
    """Test that the python discovery plugin properly respects exceptions."""
    pydp = PythonDiscoveryPlugin()
    if not pydp.file_command_exists():
        pytest.skip("File command does not exist. Skipping test that requires it.")
    package = Package(
        "valid_package", os.path.join(os.path.dirname(__file__), "valid_package")
    )
    exceptions = Exceptions(os.path.join(os.path.dirname(__file__), "exceptions.yaml"))
    pydp.scan(package, "level", exceptions)
    expected_src = ["test.py", "oddextensionpy.source"]
    # We have to add the path to each of the above...yuck
    expected_src_fullpath = [
        os.path.join(package.path, filename) for filename in expected_src
    ]
    # Neat trick to verify that two unordered lists are the same
    assert set(package["python_src"]) == set(expected_src_fullpath)
Ejemplo n.º 6
0
def test_python_discovery_plugin_no_file_cmd():
    """
    Test when file command does not exist.

    Test that files are not discovered with file command output if file
    command does not exist.
    """
    with modified_environ(PATH=''):
        pydp = PythonDiscoveryPlugin()
        package = Package(
            'valid_package',
            os.path.join(os.path.dirname(__file__), 'valid_package'))
        pydp.scan(package, 'level')
        expected = ['test.py', 'ignore_this/ignoreme.py']
        # We have to add the path to each of the above...yuck
        expected_fullpath = [
            os.path.join(package.path, filename) for filename in expected
        ]
        # Neat trick to verify that two unordered lists are the same
        assert set(package['python_src']) == set(expected_fullpath)