Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

html_report_line_profiler-0.0.2.tar.gz (14.6 kB view details)

Uploaded Source

Built Distribution

html_report_line_profiler-0.0.2-py3-none-any.whl (18.1 kB view details)

Uploaded Python 3

File details

Details for the file html_report_line_profiler-0.0.2.tar.gz.

File metadata

File hashes

Hashes for html_report_line_profiler-0.0.2.tar.gz
Algorithm Hash digest
SHA256 3b7ac36517e1d157a2b41a07a4b3a72112b69f8abbf0ce1a28ec5186f07f7965
MD5 0474e073473b16d5937a56aa0c3b7efb
BLAKE2b-256 f0f35e8193d1117a723b8a260f8eeccc9b0ef4df7ff3ace6287c908838277f73

See more details on using hashes here.

File details

Details for the file html_report_line_profiler-0.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for html_report_line_profiler-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 37bd5f3f89d95566aecde768ef2e1249a64a8c94193ee0f647b51e4d8ae4e578
MD5 d07be7f6df13884c99901f39afc2e942
BLAKE2b-256 f2d4a92afffb29d2815b74b8aad6fbebb4f00a158dccaba322a6d49748233875

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page