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, silent_comment

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

@silent_comment("Silent comment")
def test_silent(arg):
    print("Only this gets printed")

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
from codorectorate import comment


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 codecorate

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-1.0.0.tar.gz (3.1 kB view details)

Uploaded Source

Built Distribution

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

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

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for codorectorate-1.0.0.tar.gz
Algorithm Hash digest
SHA256 64cffaa3d863ff14ba936ed7597506a47684a3495b7c8f97862c67d32fabd5c1
MD5 65d5e6e5609def2629152385d96ec67a
BLAKE2b-256 5b87256d7fdf3bd69b26dee8e3de88d69c72c45aad14eb43b16480cce5d8848a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: codorectorate-1.0.0-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-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7d83da27355cf9ec0e120aec08394b9d9ecc3f1cdfd1a63880184d427c0f0b6a
MD5 c8a4e6dea5b4e718b5511a9bc1dc0617
BLAKE2b-256 9646fae0af024ffdf9370e3e8d015be19dc2b8de1e91f769025483293c5a34bc

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