Generate an HTML report for line_parser
Project description
Utilisation :
A ajouter a un test unittaire unittest, et à lancer avec $ coverage run -m unittest test_str.py
Dans :
class Test_CeciEstUnTest(unittest.TestCase):
def setUp(self):
# Code execute avant chaque test
[...] # ce que l'on veut
# Profiler :
if os.environ.get("PROFILING", False).lower() == "time":
os.environ["PROFILING"] = "1"
self.delete_profiling_env = True
self.profiler = LineProfiler()
self.profiler.add_function(str2digit)
self.profiler.enable_by_count()
#endIf
#endDef
# ...
def tearDown(self):
# Code executé après chaque test
# Terminer le profiler en premier
if os.environ.get("PROFILING", False).lower() == "time":
output_folder = "./profile_time/"
self.profiler.disable_by_count()
os.makedirs(output_folder, exist_ok=True) # Creer si necessaire le dossier
test_method_name = self._testMethodName
class_name = self.__class__.__name__
# Ecriture du fichier .lprof
filename = f"{class_name}_{test_method_name}.lprof".replace("Test_","")
outfile = os.path.join(output_folder, filename)
self.profiler.dump_stats(outfile)
print(f">> WRITE {outfile}")
# Ecriture du fichier texte
outfile = outfile.replace(".lprof", ".dat")
output_stream = io.StringIO()
self.profiler.print_stats(stream=output_stream)
stats_output = output_stream.getvalue()
with open(outfile, "w") as f:
f.write(stats_output)
#
print(f">> WRITE {outfile}")
# Affichage a l'ecran
self.profiler.print_stats()
# Supprimer la variable d'environnement
if self.delete_profiling_env:
del os.environ["PROFILING"]
#
#
# [...] # Les autres commandes
#endDef
#endClass
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file html_report_line_profiler-0.0.1.tar.gz
.
File metadata
- Download URL: html_report_line_profiler-0.0.1.tar.gz
- Upload date:
- Size: 11.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 525fb7ce795f80c0565e1340cf65b35a936e8fa80da77dfae5d2afc92e0977a9 |
|
MD5 | f4a6c77af5cc5a847622b80e1377a4ac |
|
BLAKE2b-256 | 432228ee348aa94e59587c5d7f02f23e163701420c6fdead12444e4cb3b26fd6 |
File details
Details for the file html_report_line_profiler-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: html_report_line_profiler-0.0.1-py3-none-any.whl
- Upload date:
- Size: 14.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1bad37a19072c59177046f1193d498b18cdabfc3d15aa9294bd1178a1f85837a |
|
MD5 | 918bc17fb2dd00f9c6fd2a5a0d062d61 |
|
BLAKE2b-256 | dd50effb735c2b39d6b86d17b0503b797d82ef5dae23e623772869b72c0549e1 |