def test_from_reqs_file_comments(tmpdir): f = tmpdir.join('reqs.txt') f.write( '\n' '# hello world\n' 'six # more comments\n', ) expected = (Depends('X', 'python', 'six', ''),) assert tuple(python.from_reqs_file('X', f)) == expected
def test_fomr_reqs_file_editable_git(tmpdir): f = tmpdir.join('reqs.txt') f.write('-e git+https://github.com/asottile/cfgv') expected = ( Depends( 'X', 'python', '-e git+https://github.com/asottile/cfgv', ' (unable to parse)', ), ) assert tuple(python.from_reqs_file('X', f)) == expected
def requirements_tools() -> Tuple[Depends, ...]: reqs_minimal = 'requirements-minimal.txt' reqs = 'requirements.txt' reqs_dev_minimal = 'requirements-dev-minimal.txt' reqs_dev = 'requirements-dev.txt' ret: List[Depends] = [] if os.path.exists(reqs_minimal) and os.path.exists(reqs): ret.extend(python.from_reqs_file('DEPENDS', reqs_minimal)) ret.extend(python.from_reqs_file('REQUIRES', reqs)) elif os.path.exists(reqs): ret.extend(python.from_reqs_file('REQUIRES', reqs)) if os.path.exists(reqs_dev_minimal) and os.path.exists(reqs_dev): ret.extend(python.from_reqs_file('DEPENDS_DEV', reqs_dev_minimal)) ret.extend(python.from_reqs_file('REQUIRES_DEV', reqs_dev)) elif os.path.exists(reqs_dev): ret.extend(python.from_reqs_file('DEPENDS_DEV', reqs_dev)) return tuple(ret)
def test_from_reqs_file_ignores_local_paths(tmpdir): f = tmpdir.join('reqs.txt') f.write('-e foo\n-e .\nsix\n') tmpdir.join('foo').ensure_dir() expected = (Depends('X', 'python', 'six', ''),) assert tuple(python.from_reqs_file('X', f)) == expected