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
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
python3 -m buildtwine upload dist/*
pip3 install codecorate
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file codorectorate-0.0.2.tar.gz.
File metadata
- Download URL: codorectorate-0.0.2.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c34d609c70428be5af1efcff1a6253bd9adb90ae8a4f1cbab89477842425c9a3
|
|
| MD5 |
817a10f4206d20e199f8999ee2b78c7f
|
|
| BLAKE2b-256 |
24f6644d021849c44fcc725a83a795344a6c2f4c137272b17675237fcd0f43ef
|
File details
Details for the file codorectorate-0.0.2-py3-none-any.whl.
File metadata
- Download URL: codorectorate-0.0.2-py3-none-any.whl
- Upload date:
- Size: 4.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e8259f7c4656a5d4989b19637951ea0aeba083aaf9840cfca8e88462535f61fa
|
|
| MD5 |
f75f8f13542b37db3b93066cac280d92
|
|
| BLAKE2b-256 |
d60631a0512bed66b4b4416f2edbdba0bb53b474ea0c205ff0d4da6756999012
|