Skip to main content

Uses decorators to print comments before function invocation

Project description

Codorectorate

Simple util module that makes it possible to use decorators to comment before a function or method is run. Useful in E2E testing using Selenium or just normally when running code that should be manually verified to run.

Example - simple

from codorectorate import comment

@comment("Hello")
def test(arg):
    print("world")

Example - in tests

import os
import time
import requests
from django.contrib.staticfiles.testing import StaticLiveServerTestCase
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from http import HTTPStatus

def comment(argument):
    def decorator(function):
        def wrapper(*args, **kwargs):
            print(argument)
            result = function(*args, **kwargs)
            return result
        return wrapper
    return decorator

class TestNavigationTabs(StaticLiveServerTestCase):
    def setUp(self):
        options = Options()
        IS_CI = os.environ.get('CI')
        if IS_CI:
            print("Running Acceptance Test in headless mode because of CI")
            options.add_argument("--headless")
        self.browser = webdriver.Chrome(options=options)

    def tearDown(self):
        self.browser.quit()

    @comment("Selenium doesnt expose status code in their API")
    def test_404(self):
        url = f'{self.live_server_url}/nosuchurl/'
        self.browser.get(url)
        response = requests.head(url)
        self.assertEqual(response.status_code, HTTPStatus.NOT_FOUND)
        

Publishing

  1. python3 -m build
  2. twine upload dist/*

pip3 install comment-decorator

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

codorectorate-0.0.1.tar.gz (3.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

codorectorate-0.0.1-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

Details for the file codorectorate-0.0.1.tar.gz.

File metadata

  • Download URL: codorectorate-0.0.1.tar.gz
  • Upload date:
  • Size: 3.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for codorectorate-0.0.1.tar.gz
Algorithm Hash digest
SHA256 c2258cfe178beebd952e086a3da1b9698766a3868421bdd53ccdd72297b23b89
MD5 ccb67f88e9a58220bd9d7ac6a3635890
BLAKE2b-256 a52a9653ad9e0ee2cb65540212091236c1084bcf2fd6225cae02769f6a8c7873

See more details on using hashes here.

File details

Details for the file codorectorate-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: codorectorate-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 4.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for codorectorate-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 82fa965632112daa1c58bd72582114afe2935373b3be11912094dbaa45b8f55d
MD5 7044a94837209aa63a9dfcee25971078
BLAKE2b-256 2587a85fa768150e8f355d4433069b7d94ea8c4e70a9e63cf75c913cccce2882

See more details on using hashes here.

Supported by

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