Skip to content

Commit d46db1d

Browse files
Merge pull request #22 from JamalZeynalov/18-add-option-to-suppress-output-of-coveragereportergenerate_report
Add DEBUG_MODE option
2 parents a566b56 + 65880ba commit d46db1d

File tree

4 files changed

+11
-4
lines changed

4 files changed

+11
-4
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ API_DOCS_TYPE="swagger" # Note: "openapi" is default type of API docs
3838
API_DOCS_VERSION="2.0" # Note: "3.0.0" is default version of API docs
3939
API_DOCS_FORMAT="yaml" # Note: "json" is default format of API docs and output files
4040
API_COVERAGE_REPORTS_DISABLED=True # Skip requests recording. No files will be saved to 'swagger-coverage-output' dir
41+
DEBUG_MODE=True # Enable debug mode. All commandline logs will be printed to console (False by default)
4142
4243
```
4344

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
setup(
77
name="swagger-coverage",
8-
version="3.0.0",
8+
version="3.1.0",
99
author="Jamal Zeinalov",
1010
author_email="jamal.zeynalov@gmail.com",
1111
description='Python adapter for "swagger-coverage" tool',

swagger_coverage_py/configs.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,5 @@
1010
API_DOCS_VERSION = env.str("API_DOCS_VERSION", default="3.0.0") # "2.0"
1111
API_DOCS_FORMAT = env.str("API_DOCS_FORMAT", default="json") # "yaml"
1212
IS_DISABLED = env.bool("API_COVERAGE_REPORTS_DISABLED", default=False) # If True then requests won't be recorded
13+
14+
DEBUG_MODE = env.bool("DEBUG_MODE", default=False) # Set to True to see commandline output

swagger_coverage_py/reporter.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,17 @@
22
import platform
33
import re
44
import shutil
5+
import subprocess
56
from pathlib import Path
67

78
import requests
89

9-
from swagger_coverage_py.configs import API_DOCS_FORMAT
10+
from swagger_coverage_py.configs import API_DOCS_FORMAT, DEBUG_MODE
1011
from swagger_coverage_py.docs_writers.api_doc_writer import write_api_doc_to_file
1112

1213

1314
class CoverageReporter:
14-
def __init__(self, api_name: str, host: str, verify:bool = True):
15+
def __init__(self, api_name: str, host: str, verify: bool = True):
1516
self.host = host
1617
self.verify = verify
1718
self.swagger_doc_file = f"swagger-doc-{api_name}.{API_DOCS_FORMAT}"
@@ -64,7 +65,10 @@ def generate_report(self):
6465
command if platform.system() != "Windows" else command.replace("/", "\\")
6566
)
6667

67-
os.system(command)
68+
# Suppress all output if not in debug mode
69+
command = command + " > /dev/null 2>&1" if not DEBUG_MODE else command
70+
71+
subprocess.run(command, shell=True)
6872

6973
def cleanup_input_files(self):
7074
shutil.rmtree(self.output_dir, ignore_errors=True)

0 commit comments

Comments
 (0)