use python API for tests

Before:
real	0m4.807s
user	0m3.817s
sys	0m0.920s

After:
real	0m1.236s
user	0m1.011s
sys	0m0.222s

Multiply by number of testcases we didn't implement yet and by
python versions we want to test on.

Signed-off-by: Igor Gnatenko <ignatenkobrain@fedoraproject.org>
This commit is contained in:
Igor Gnatenko 2017-02-05 21:06:40 +01:00
parent 67a12b527f
commit 8155c69e38

15
test.py
View file

@ -7,6 +7,8 @@ import textwrap
import pytest
from rust2rpm import Metadata
DUMMY_LIB = """
pub fn say_hello() {
println!("Hello, World!");
@ -36,12 +38,6 @@ def cargo_toml(request):
return make_cargo_toml
def run(*params):
cmd = [sys.executable, DEPGEN, *params]
out = subprocess.check_output(cmd, universal_newlines=True)
return out.split("\n")[:-1]
@pytest.mark.parametrize("toml, provides, requires, conflicts", [
# Basic provides
@ -278,6 +274,7 @@ def run(*params):
])
def test_depgen(toml, provides, requires, conflicts, cargo_toml):
assert run("--provides", cargo_toml(toml)) == provides
assert run("--requires", cargo_toml(toml)) == requires
assert run("--conflicts", cargo_toml(toml)) == conflicts
md = Metadata.from_file(cargo_toml(toml))
assert [str(x) for x in md.provides] == provides
assert [str(x) for x in md.requires] == requires
assert [str(x) for x in md.conflicts] == conflicts