Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests #1

Merged
merged 8 commits into from Sep 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 10 additions & 0 deletions .coveragerc
@@ -0,0 +1,10 @@
# .coveragerc to control coverage.py

[report]
# Regexes for lines to exclude from consideration
exclude_lines =
# Have to re-enable the standard pragma:
pragma: no cover

# Don't complain if non-runnable code isn't run:
if __name__ == .__main__.:
21 changes: 21 additions & 0 deletions .editorconfig
@@ -0,0 +1,21 @@
# Top-most EditorConfig file
root = true

# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true
charset = utf-8

# Four-space indentation
[*.py]
indent_size = 4
indent_style = space
trim_trailing_whitespace = true

[tabulated_rst.py]
trim_trailing_whitespace = false

# Two-space indentation
[*.yml]
indent_size = 2
40 changes: 40 additions & 0 deletions .github/workflows/lint.yml
@@ -0,0 +1,40 @@
name: Lint

on: [push, pull_request]

env:
FORCE_COLOR: 1

jobs:
build:
runs-on: ubuntu-20.04

steps:
- uses: actions/checkout@v2

- name: Cache
uses: actions/cache@v2
with:
path: |
~/.cache/pip
~/.cache/pre-commit
key:
lint-v2-${{ hashFiles('**/setup.py') }}-${{
hashFiles('**/.pre-commit-config.yaml') }}
restore-keys: |
lint-v2-

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.8

- name: Install dependencies
run: |
python -m pip install -U pip
python -m pip install -U tox

- name: Lint
run: tox -e lint
env:
PRE_COMMIT_COLOR: always
69 changes: 69 additions & 0 deletions .github/workflows/test.yml
@@ -0,0 +1,69 @@
name: Test

on: [push, pull_request]

env:
FORCE_COLOR: 1

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
python-version: ["3.6", "3.7", "3.8", "3.9-dev"]
os: [ubuntu-latest, macos-latest, windows-latest]
include:
# Include new variables for Codecov
- { codecov-flag: GHA_Ubuntu, os: ubuntu-latest }
- { codecov-flag: GHA_macOS, os: macos-latest }
- { codecov-flag: GHA_Windows, os: windows-latest }
# Deadsnakes versions
- { python-version: 3.10-dev, os: ubuntu-latest }

steps:
- uses: actions/checkout@v2

- name: Set up Python ${{ matrix.python-version }} (deadsnakes)
uses: deadsnakes/action@v1.0.0
if: contains(matrix.python-version, '3.10-dev')
with:
python-version: ${{ matrix.python-version }}

- name: Set up Python ${{ matrix.python-version }}
if: "!contains(matrix.python-version, '3.10-dev')"
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Get pip cache dir
id: pip-cache
run: |
echo "::set-output name=dir::$(pip cache dir)"

- name: Cache
uses: actions/cache@v2
with:
path: ${{ steps.pip-cache.outputs.dir }}
key:
${{ matrix.os }}-${{ matrix.python-version }}-v2-${{
hashFiles('**/setup.py') }}
restore-keys: |
${{ matrix.os }}-${{ matrix.python-version }}-v2-

- name: Install dependencies
run: |
python -m pip install -U pip
python -m pip install -U wheel
python -m pip install -U tox

- name: Tox tests
shell: bash
run: |
tox -e py

- name: Upload coverage
uses: codecov/codecov-action@v1
with:
flags: ${{ matrix.codecov-flag }}
name: ${{ matrix.os }} Python ${{ matrix.python-version }}
44 changes: 44 additions & 0 deletions .pre-commit-config.yaml
@@ -0,0 +1,44 @@
repos:
- repo: https://github.com/asottile/pyupgrade
rev: v2.7.2
hooks:
- id: pyupgrade
args: ["--py36-plus"]

- repo: https://github.com/psf/black
rev: 20.8b1
hooks:
- id: black
args: ["--target-version", "py36"]
# override until resolved: https://github.com/psf/black/issues/402
files: \.pyi?$
types: []

- repo: https://github.com/PyCQA/isort
rev: 5.5.1
hooks:
- id: isort

- repo: https://gitlab.com/pycqa/flake8
rev: 3.8.3
hooks:
- id: flake8
additional_dependencies: [flake8-2020, flake8-implicit-str-concat]

- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.6.0
hooks:
- id: python-check-blanket-noqa

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
hooks:
- id: check-merge-conflict
- id: check-toml
- id: check-yaml

- repo: https://github.com/prettier/prettier
rev: 2.1.1
hooks:
- id: prettier
args: [--prose-wrap=always, --print-width=88]
46 changes: 23 additions & 23 deletions README.md
Expand Up @@ -25,39 +25,39 @@ cprint("Attention!", "red", attrs=["bold"], file=sys.stderr)

Text colors:

- grey
- red
- green
- yellow
- blue
- magenta
- cyan
- white
- grey
- red
- green
- yellow
- blue
- magenta
- cyan
- white

Text highlights:

- on_grey
- on_red
- on_green
- on_yellow
- on_blue
- on_magenta
- on_cyan
- on_white
- on_grey
- on_red
- on_green
- on_yellow
- on_blue
- on_magenta
- on_cyan
- on_white

Attributes:

- bold
- dark
- underline
- blink
- reverse
- concealed
- bold
- dark
- underline
- blink
- reverse
- concealed

## Terminal properties

| Terminal | bold | dark | underline | blink | reverse | concealed |
|--------------|---------|------|---------- |------------|---------|-----------|
| ------------ | ------- | ---- | --------- | ---------- | ------- | --------- |
| xterm | yes | no | yes | bold | yes | yes |
| linux | yes | yes | bold | yes | yes | no |
| rxvt | yes | no | yes | bold/black | yes | no |
Expand Down
5 changes: 5 additions & 0 deletions pyproject.toml
@@ -0,0 +1,5 @@
[tool.black]
target_version = ["py36"]

[tool.isort]
profile = "black"
2 changes: 2 additions & 0 deletions setup.cfg
@@ -0,0 +1,2 @@
[flake8]
max_line_length = 88
65 changes: 42 additions & 23 deletions setup.py
@@ -1,5 +1,4 @@
#!/usr/bin/env python
# coding: utf-8
# Copyright (c) 2008-2011 Volvox Development Team
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
Expand Down Expand Up @@ -33,25 +32,45 @@ def local_scheme(version):
to be able to upload to Test PyPI"""
return ""

setup(name='termcolor',
description='ANSII Color formatting for output in terminal.',
long_description=long_description,
long_description_content_type="text/markdown",
author='Konstantin Lepa',
license='MIT',
author_email='konstantin.lepa@gmail.com',
url='http://pypi.python.org/pypi/termcolor',
packages=find_packages(where="src"),
package_dir={"": "src"},
use_scm_version={"local_scheme": local_scheme},
setup_requires=["setuptools_scm"],
classifiers=[
'Development Status :: 5 - Production/Stable',
'Environment :: Console',
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Topic :: Terminals'
]
)

setup(
name="termcolor",
description="ANSII color formatting for output in terminal",
long_description=long_description,
long_description_content_type="text/markdown",
author="Konstantin Lepa",
url="https://github.com/hugovk/termcolor",
project_urls={"Source": "https://github.com/hugovk/termcolor"},
license="MIT",
author_email="konstantin.lepa@gmail.com",
keywords=[
"termcolor",
"terminal",
"ANSII color",
"ANSII colour",
"ANSII",
"color",
"colour",
"formatting",
],
packages=find_packages(where="src"),
package_dir={"": "src"},
use_scm_version={"local_scheme": local_scheme},
setup_requires=["setuptools_scm"],
extras_require={"tests": ["pytest", "pytest-cov"]},
python_requires=">=3.6",
classifiers=[
"Development Status :: 5 - Production/Stable",
"Environment :: Console",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3 :: Only",
"Topic :: Terminals",
],
)
20 changes: 18 additions & 2 deletions src/termcolor/__init__.py
@@ -1,3 +1,19 @@
from termcolor.termcolor import colored, cprint
from termcolor.termcolor import (
ATTRIBUTES,
COLORS,
HIGHLIGHTS,
RESET,
VERSION,
colored,
cprint,
)

__all__ = ["colored", "cprint"]
__all__ = [
"ATTRIBUTES",
"COLORS",
"HIGHLIGHTS",
"RESET",
"VERSION",
"colored",
"cprint",
]