Beispiel #1
0
def test_version_file_has___version__(tmpdir):
    with tmpdir.as_cwd():
        version_file = helpers.package_file_path('_version.py', PACKAGE_NAME)
        _make_package(PACKAGE_NAME, empty_module_files=[os.path.basename(version_file)])
        assert project.version_file_has___version__(PACKAGE_NAME) is False
        snippet_content = snippets.get_snippet_content('_version.py')
        with open(version_file, 'a') as _version_py:
            _version_py.write(snippet_content)
        assert project.version_file_has___version__(PACKAGE_NAME) is True
Beispiel #2
0
def test_setup_py_uses__version_py(tmpdir):
    with tmpdir.as_cwd():
        open('setup.py', 'w').close()
        assert project.setup_py_uses__version_py() is False
        snippet_content = snippets.get_snippet_content(
            snippet_name='setup.py',
            package_name=PACKAGE_NAME
        )
        with open('setup.py', 'a') as setup_py:
            setup_py.write(snippet_content)
        assert project.setup_py_uses__version_py() is True
Beispiel #3
0
def test_set_version(tmpdir):
    with tmpdir.as_cwd():
        version_file = helpers.package_file_path('_version.py', PACKAGE_NAME)
        _make_package(PACKAGE_NAME, empty_module_files=[os.path.basename(version_file)])
        snippet_content = snippets.get_snippet_content('_version.py')
        with open(version_file, 'w') as _version_py:
            _version_py.write(snippet_content)
        project.set_version(PACKAGE_NAME, '1.2.3')
        version_file_content = helpers.get_file_content(version_file)
        found = funcy.re_find(project.VERSION_SET_REGEX, version_file_content)
        assert found['version'] == '1.2.3'
Beispiel #4
0
def test_get_snippet_content():
    with pytest.raises(ValueError):
        snippets.get_snippet_content('notasnippet')
    assert '__version__' in snippets.get_snippet_content('_version.py')
    with pytest.raises(KeyError):
        snippets.get_snippet_content('setup.py', badkey='badval')
    ret = snippets.get_snippet_content(snippet_name='setup.py',
                                       package_name='mypackage',
                                       version_file='_version.py')
    assert '_version.py' in ret
    assert 'exec' in ret
Beispiel #5
0
def test_get_version(tmpdir):
    with tmpdir.as_cwd():
        with pytest.raises(IOError):
            project.get_version(PACKAGE_NAME)
        version_file = helpers.package_file_path('_version.py', PACKAGE_NAME)
        _make_package(PACKAGE_NAME, empty_module_files=[os.path.basename(version_file)])
        with pytest.raises(project.ProjectError):
            project.get_version(PACKAGE_NAME)
        with open(version_file, 'w') as _version_py:
            _version_py.write("__version__='someversion'")
        with microcache.temporarily_enabled():
            assert project.get_version(PACKAGE_NAME) == 'someversion'
            snippet_content = snippets.get_snippet_content('_version.py')
            with open(version_file, 'w') as _version_py:
                _version_py.write(snippet_content)
            assert project.get_version(PACKAGE_NAME) == 'someversion'
            assert project.get_version(PACKAGE_NAME, ignore_cache=True) == 'managed by hatchery'
Beispiel #6
0
def test_get_snippet_content():
    with pytest.raises(ValueError):
        snippets.get_snippet_content('notasnippet')
    assert '__version__' in snippets.get_snippet_content('_version.py')
    with pytest.raises(KeyError):
        snippets.get_snippet_content('setup.py', badkey='badval')
    ret = snippets.get_snippet_content(
        snippet_name='setup.py',
        package_name='mypackage',
        version_file='_version.py'
    )
    assert '_version.py' in ret
    assert 'exec' in ret