コード例 #1
0
def test_underscore_replacement():
    context = {
        'name': 'dummy-0.0.0',
    }
    filename = '__init__.py.jj2'
    rendered = get_rendered_file(filename, context)
    assert 'dummy_0.0.0' in rendered
    assert 'dummy-0.0.0' not in rendered
コード例 #2
0
def test_setup():
    filename = 'setup.py.jj2'
    with open(os.path.join("config", "data.yml")) as f:
        content = f.read()
    yaml = YAML(typ='safe')
    context = yaml.load(content)
    print(context)
    rendered = get_rendered_file(filename, context)
    expected = get_file_content('setup.py.output')
    assert expected == rendered
コード例 #3
0
def test_manifest():
    filename = 'MANIFEST.in.jj2'
    rendered = get_rendered_file(filename, {})
    expected_manifest = textwrap.dedent("""\
    include README.rst
    include LICENSE
    include CHANGELOG.rst
    recursive-include tests *
    """)
    assert expected_manifest == rendered
コード例 #4
0
def test_version():
    context = {
        'author': 'author_name',
        'version': '0.0.1',
        'something_else': 'hello world',
    }
    filename = '_version.py.jj2'
    rendered = get_rendered_file(filename, context)
    assert 'author_name' in rendered
    assert '0.0.1' in rendered
    assert 'hello world' not in rendered
コード例 #5
0
def test_NEW_BSD_LICENSE():
    filename = 'NEW_BSD_LICENSE.jj2'
    context = {
        'copyright_year': '2018',
        'company': 'dummy',
        'name': 'first last',
        'something_else': 'hello world',
    }
    rendered = get_rendered_file(filename, context)
    assert '2018' in rendered
    assert 'dummy' in rendered
    assert 'first last' in rendered
    assert 'hello world' not in rendered
コード例 #6
0
def test_requirements():
    context = {
        'dependencies': [
            'dependency',
            'dependency #with_comment',
            'dependency#with_comment_no_space',
            'dependency#egg=dependency',
            'git+https://github.com/user/repo#egg=repo',
            '# actual comment',
        ]
    }
    filename = 'requirements.txt.jj2'
    rendered = get_rendered_file(filename, context)
    expected_requirements = textwrap.dedent("""\
           dependency
           dependency #with_comment
           dependency#with_comment_no_space
           dependency#egg=dependency
           git+https://github.com/user/repo#egg=repo
           # actual comment
    """)
    assert expected_requirements == rendered