Commit 209c6269 authored by Stephen Thompson's avatar Stephen Thompson

Issue #1 added a unit test to check that setup.py and requirements match

parent 6de810d7
# coding=utf-8
"""scikit-surgery-evaluation tests"""
import pytest
# Pytest style
def test_requirements_vs_setup():
"""
Test that the requirements file matches setup.py
"""
# setup=open("setup.py","r")
# setuptxt = setup.read()
# setup.close()
with open("setup.py", "r") as f:
searchlines=f.readlines()
install_line = -1
for i, line in enumerate(searchlines):
if "install_requires" in line:
install_line = i
break
end_line = -1
for i, line in enumerate(searchlines[install_line:]):
if "]" in line:
end_line = install_line + i
break
setup_reqs = []
for line in searchlines[install_line + 1: end_line]:
req = line.replace(',', '').replace("'", "")
req = req.replace(' ', '').replace('\n','')
setup_reqs.append(req)
with open("requirements.txt","r") as f:
searchlines=f.readlines()
reqs = []
for line in searchlines:
if "#" not in line:
reqs.append(line.replace('\n',''))
for setup_req in setup_reqs:
assert setup_req in reqs
for req in reqs:
assert req in setup_reqs
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment