Skip to content

Commit

Permalink
Merge branch 'develop' into feature/pr82
Browse files Browse the repository at this point in the history
  • Loading branch information
ikirudennis committed Aug 5, 2024
2 parents 89310f3 + f930788 commit e53ce3a
Show file tree
Hide file tree
Showing 33 changed files with 347 additions and 224 deletions.
6 changes: 6 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[flake8]
ignore =
# line too long
E501
exclude =
build/
33 changes: 33 additions & 0 deletions .github/workflows/lint_and_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
name: python-textile

on: [push]

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "pypy3.10"]
image_size: ['true', 'false']
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Python flake8 Lint
uses: py-actions/flake8@v2.3.0
- name: Install dependencies
run: |
imagesize=''
pip install -U pytest pytest-cov coverage codecov
if [[ ${{ matrix.image_size }} == true ]] ; then imagesize='[imagesize]' ; fi
pip install -e ".${imagesize}"
- name: run tests
run: |
pytest
- name: Codecov
uses: codecov/codecov-action@v4
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
23 changes: 0 additions & 23 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion README.textile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
!https://travis-ci.org/textile/python-textile.svg!:https://travis-ci.org/textile/python-textile !https://codecov.io/github/textile/python-textile/coverage.svg!:https://codecov.io/github/textile/python-textile !https://img.shields.io/pypi/pyversions/textile! !https://img.shields.io/pypi/wheel/textile!
!https://github.com/textile/python-textile/actions/workflows/lint_and_test.yml/badge.svg(python-textile)!:https://github.com/textile/python-textile/actions/workflows/lint_and_test.yml !https://codecov.io/github/textile/python-textile/coverage.svg!:https://codecov.io/github/textile/python-textile !https://img.shields.io/pypi/pyversions/textile! !https://img.shields.io/pypi/wheel/textile!

h1. python-textile

Expand Down
15 changes: 7 additions & 8 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
from setuptools import setup, find_packages
from setuptools.command.test import test as TestCommand
import os
import sys
from setuptools import setup, find_packages


def get_version():
Expand All @@ -12,6 +10,7 @@ def get_version():
return variables.get('VERSION')
raise RuntimeError('No version info found.')


setup(
name='textile',
version=get_version(),
Expand All @@ -29,18 +28,18 @@ def get_version():
'Programming Language :: Python',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3 :: Only',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
'Topic :: Software Development :: Libraries :: Python Modules',
],
keywords='textile,text,html markup',
install_requires=[
'html5lib>=1.0.1',
'regex>1.0; implementation_name != "pypy"',
],
],
extras_require={
'develop': ['pytest', 'pytest-cov'],
'imagesize': ['Pillow>=3.0.0'],
Expand All @@ -49,5 +48,5 @@ def get_version():
tests_require=['pytest', 'pytest-cov'],
include_package_data=True,
zip_safe=False,
python_requires='>=3.5',
python_requires='>=3.8',
)
2 changes: 1 addition & 1 deletion tests/fixtures/README.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<p><a href="https://travis-ci.org/textile/python-textile"><img alt="" src="https://travis-ci.org/textile/python-textile.svg" /></a> <a href="https://codecov.io/github/textile/python-textile"><img alt="" src="https://codecov.io/github/textile/python-textile/coverage.svg" /></a> <img alt="" src="https://img.shields.io/pypi/pyversions/textile" /> <img alt="" src="https://img.shields.io/pypi/wheel/textile" /></p>
<p><a href="https://github.com/textile/python-textile/actions/workflows/lint_and_test.yml"><img alt="python-textile" src="https://github.com/textile/python-textile/actions/workflows/lint_and_test.yml/badge.svg" title="python-textile" /></a> <a href="https://codecov.io/github/textile/python-textile"><img alt="" src="https://codecov.io/github/textile/python-textile/coverage.svg" /></a> <img alt="" src="https://img.shields.io/pypi/pyversions/textile" /> <img alt="" src="https://img.shields.io/pypi/wheel/textile" /></p>

<h1>python-textile</h1>

Expand Down
2 changes: 1 addition & 1 deletion tests/test_attributes.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from textile.utils import parse_attributes
import re


def test_parse_attributes():
assert parse_attributes('\\1', element='td') == {'colspan': '1'}
Expand Down
13 changes: 9 additions & 4 deletions tests/test_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
except ImportError:
from ordereddict import OrderedDict


def test_block():
t = textile.Textile()
result = t.block('h1. foobar baby')
Expand All @@ -16,15 +17,14 @@ def test_block():

b = Block(t, "bq", "", None, "", "Hello BlockQuote")
expect = ('blockquote', OrderedDict(), 'p', OrderedDict(),
'Hello BlockQuote')
'Hello BlockQuote')
result = (b.outer_tag, b.outer_atts, b.inner_tag, b.inner_atts, b.content)
assert result == expect

b = Block(t, "bq", "", None, "http://google.com", "Hello BlockQuote")
citation = '{0}1:url'.format(t.uid)
expect = ('blockquote', OrderedDict([('cite',
'{0.uid}{0.refIndex}:url'.format(t))]), 'p', OrderedDict(),
'Hello BlockQuote')
'{0.uid}{0.refIndex}:url'.format(t))]), 'p', OrderedDict(),
'Hello BlockQuote')
result = (b.outer_tag, b.outer_atts, b.inner_tag, b.inner_atts, b.content)
assert result == expect

Expand All @@ -40,6 +40,7 @@ def test_block():
result = (b.outer_tag, b.outer_atts, b.inner_tag, b.inner_atts, b.content)
assert result == expect


def test_block_tags_false():
t = textile.Textile(block_tags=False)
assert t.block_tags is False
Expand All @@ -48,13 +49,15 @@ def test_block_tags_false():
expect = 'test'
assert result == expect


def test_blockcode_extended():
input = 'bc.. text\nmoretext\n\nevenmoretext\n\nmoremoretext\n\np. test'
expect = '<pre><code>text\nmoretext\n\nevenmoretext\n\nmoremoretext</code></pre>\n\n\t<p>test</p>'
t = textile.Textile()
result = t.parse(input)
assert result == expect


def test_blockcode_in_README():
with open('README.textile') as f:
readme = ''.join(f.readlines())
Expand All @@ -63,13 +66,15 @@ def test_blockcode_in_README():
expect = ''.join(f.readlines())
assert result == expect


def test_blockcode_comment():
input = '###.. block comment\nanother line\n\np. New line'
expect = '\t<p>New line</p>'
t = textile.Textile()
result = t.parse(input)
assert result == expect


def test_extended_pre_block_with_many_newlines():
"""Extra newlines in an extended pre block should not get cut down to only
two."""
Expand Down
14 changes: 8 additions & 6 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,30 @@

import textile


def test_console_script():
command = [sys.executable, '-m', 'textile', 'README.textile']
try:
result = subprocess.check_output(command)
except AttributeError:
command[2] = 'textile.__main__'
result = subprocess.Popen(command,
stdout=subprocess.PIPE).communicate()[0]
result = subprocess.Popen(
command, stdout=subprocess.PIPE).communicate()[0]
with open('tests/fixtures/README.txt') as f:
expect = ''.join(f.readlines())
if type(result) == bytes:
if isinstance(result, bytes):
result = result.decode('utf-8')
assert result == expect


def test_version_string():
command = [sys.executable, '-m', 'textile', '-v']
try:
result = subprocess.check_output(command)
except AttributeError:
command[2] = 'textile.__main__'
result = subprocess.Popen(command,
stdout=subprocess.PIPE).communicate()[0]
if type(result) == bytes:
result = subprocess.Popen(
command, stdout=subprocess.PIPE).communicate()[0]
if isinstance(result, bytes):
result = result.decode('utf-8')
assert result.strip() == textile.__version__
2 changes: 1 addition & 1 deletion tests/test_footnoteRef.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from textile import Textile
import re


def test_footnoteRef():
t = Textile()
Expand Down
1 change: 1 addition & 0 deletions tests/test_getRefs.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from textile import Textile


def test_getRefs():
t = Textile()
result = t.getRefs("some text [Google]http://www.google.com")
Expand Down
1 change: 1 addition & 0 deletions tests/test_getimagesize.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

PIL = pytest.importorskip('PIL')


def test_imagesize():
assert getimagesize("http://www.google.com/intl/en_ALL/images/logo.gif") == (276, 110)
assert getimagesize("http://bad.domain/") == ''
Expand Down
Loading

0 comments on commit e53ce3a

Please sign in to comment.