mirror of
https://github.com/bndr/pipreqs.git
synced 2025-06-06 03:25:21 +00:00
Feat(tests): Add unittests
This commit is contained in:
parent
ecaec5a8d0
commit
0e22c93a99
4
tests/_data/requirements.txt
Normal file
4
tests/_data/requirements.txt
Normal file
@ -0,0 +1,4 @@
|
||||
flask==0.10.1
|
||||
requests==2.6.0
|
||||
sqlalchemy==1.0.0
|
||||
docopt==0.6.2
|
17
tests/_data/test.py
Normal file
17
tests/_data/test.py
Normal file
@ -0,0 +1,17 @@
|
||||
import atexit
|
||||
from __future__ import print_function
|
||||
from docopt import docopt
|
||||
import curses, logging, sqlite3
|
||||
import logging
|
||||
import os
|
||||
import sqlite3
|
||||
import time
|
||||
import sys
|
||||
import signal
|
||||
import requests
|
||||
import flask.ext.somext
|
||||
from sqlalchemy import model
|
||||
|
||||
|
||||
def main():
|
||||
pass
|
@ -8,7 +8,7 @@ test_pipreqs
|
||||
Tests for `pipreqs` module.
|
||||
"""
|
||||
|
||||
import unittest
|
||||
import unittest, os
|
||||
|
||||
from pipreqs import pipreqs
|
||||
|
||||
@ -16,10 +16,22 @@ from pipreqs import pipreqs
|
||||
class TestPipreqs(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
self.modules = ['flask', 'requests', 'sqlalchemy', 'docopt']
|
||||
pass
|
||||
|
||||
def test_something(self):
|
||||
pass
|
||||
def test_get_all_imports(self):
|
||||
path = os.path.join(os.path.dirname(__file__),"_data")
|
||||
imports = pipreqs.get_all_imports(path)
|
||||
self.assertEqual(len(imports),4, "Incorrect Imports array length")
|
||||
self.assertEqual(imports, self.modules, "Imports array is wrong")
|
||||
|
||||
def test_get_imports_info(self):
|
||||
path = os.path.join(os.path.dirname(__file__),"_data")
|
||||
imports = pipreqs.get_all_imports(path)
|
||||
with_info = pipreqs.get_imports_info(imports)
|
||||
self.assertEqual(len(with_info),4, "Length of imports array with info is wrong")
|
||||
for item in with_info:
|
||||
self.assertTrue(item['name'] in self.modules, "Import item appears to be missing")
|
||||
|
||||
def tearDown(self):
|
||||
pass
|
||||
|
Loading…
x
Reference in New Issue
Block a user