mirror of
https://github.com/bndr/pipreqs.git
synced 2025-06-06 19:45:22 +00:00
Merge pull request #395 from fredgrub/output_requirements_next
create test for output_requirements
This commit is contained in:
commit
acc41cc9bc
@ -8,6 +8,8 @@ test_pipreqs
|
|||||||
Tests for `pipreqs` module.
|
Tests for `pipreqs` module.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import io
|
||||||
|
import sys
|
||||||
import unittest
|
import unittest
|
||||||
import os
|
import os
|
||||||
import requests
|
import requests
|
||||||
@ -427,6 +429,49 @@ class TestPipreqs(unittest.TestCase):
|
|||||||
data = f.read().lower()
|
data = f.read().lower()
|
||||||
self.assertTrue(cleaned_module not in data)
|
self.assertTrue(cleaned_module not in data)
|
||||||
|
|
||||||
|
def test_output_requirements(self):
|
||||||
|
"""
|
||||||
|
Test --print parameter
|
||||||
|
It should print to stdout the same content as requeriments.txt
|
||||||
|
"""
|
||||||
|
|
||||||
|
capturedOutput = io.StringIO()
|
||||||
|
sys.stdout = capturedOutput
|
||||||
|
|
||||||
|
pipreqs.init(
|
||||||
|
{
|
||||||
|
"<path>": self.project,
|
||||||
|
"--savepath": None,
|
||||||
|
"--print": True,
|
||||||
|
"--use-local": None,
|
||||||
|
"--force": None,
|
||||||
|
"--proxy": None,
|
||||||
|
"--pypi-server": None,
|
||||||
|
"--diff": None,
|
||||||
|
"--clean": None,
|
||||||
|
"--mode": None,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
pipreqs.init(
|
||||||
|
{
|
||||||
|
"<path>": self.project,
|
||||||
|
"--savepath": None,
|
||||||
|
"--print": False,
|
||||||
|
"--use-local": None,
|
||||||
|
"--force": True,
|
||||||
|
"--proxy": None,
|
||||||
|
"--pypi-server": None,
|
||||||
|
"--diff": None,
|
||||||
|
"--clean": None,
|
||||||
|
"--mode": None,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
with open(self.requirements_path, "r") as f:
|
||||||
|
file_content = f.read().lower()
|
||||||
|
stdout_content = capturedOutput.getvalue().lower()
|
||||||
|
self.assertTrue(file_content == stdout_content)
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
"""
|
"""
|
||||||
Remove requiremnts.txt files that were written
|
Remove requiremnts.txt files that were written
|
||||||
|
Loading…
x
Reference in New Issue
Block a user