Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

create test for output_requirements #395

Merged
merged 1 commit into from
Oct 4, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions tests/test_pipreqs.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
Tests for `pipreqs` module.
"""

import io
import sys
import unittest
import os
import requests
Expand Down Expand Up @@ -427,6 +429,49 @@ def test_clean_with_imports_to_clean(self):
data = f.read().lower()
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()
fredgrub marked this conversation as resolved.
Show resolved Hide resolved
stdout_content = capturedOutput.getvalue().lower()
self.assertTrue(file_content == stdout_content)

def tearDown(self):
"""
Remove requiremnts.txt files that were written
Expand Down
Loading