Skip to content

Commit

Permalink
adding the tests directory plus a simple test
Browse files Browse the repository at this point in the history
adding what's needed for the tests plus one simple test
and removing a useless file
  • Loading branch information
kakwa committed Sep 2, 2013
1 parent 4b6c85f commit bd51630
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 51 deletions.
35 changes: 0 additions & 35 deletions apiary.apib

This file was deleted.

1 change: 1 addition & 0 deletions ascii_graph/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,5 +135,6 @@ def graph(self, label, data, sort=0, with_value=True):
if __name__ == '__main__':
test=[('long_label', 423), ('sl', 1234), ('line3', 531), ('line4', 200), ('line5', 834)]
graph=Pyasciigraph()
print graph.graph('test print', test)
for line in graph.graph('test print', test):
print line
3 changes: 3 additions & 0 deletions run_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh
cd `dirname $0`
python setup.py test
57 changes: 41 additions & 16 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,33 +1,58 @@
#!/usr/bin/env python
import os
import sys
from distutils.core import setup

# I really prefer Markdown to reStructuredText. PyPi does not. This allows me
# to have things how I'd like, but not throw complaints when people are trying
# to install the package and they don't have pypandoc or the README in the
# right place.
try:
import pypandoc
description = pypandoc.convert('README.md', 'rst')
import pypandoc
description = pypandoc.convert('README.md', 'rst')
except (OSError, IOError, ImportError):
description = ''
description = ''

try:
license = open('LICENSE').read()
license = open('LICENSE').read()
except IOError:
license = 'MIT'
license = 'MIT'

try:
from setuptools import setup
from setuptools.command.test import test as TestCommand

class PyTest(TestCommand):
def finalize_options(self):
TestCommand.finalize_options(self)
self.test_args = []
self.test_suite = True

def run_tests(self):
#import here, cause outside the eggs aren't loaded
import pytest
errno = pytest.main(self.test_args)
sys.exit(errno)

except ImportError:

from distutils.core import setup
PyTest = lambda x: x


setup(
name = 'ascii_graph',
version = '0.1.0',
author = 'Pierre-Francois Carpentier',
author_email = '[email protected]',
packages = ['ascii_graph'],
scripts = [],
url = 'https://github.com/kakwa/ascii_graph',
license = license,
description = 'A simple python lib to print data as ascii histograms.',
long_description = description,
install_requires = [],
name = 'ascii_graph',
version = '0.1.0',
author = 'Pierre-Francois Carpentier',
author_email = '[email protected]',
packages = ['ascii_graph'],
scripts = [],
url = 'https://github.com/kakwa/ascii_graph',
license = license,
description = 'A simple python lib to print data as ascii histograms.',
long_description = description,
install_requires = [],
tests_require=['pytest'],
cmdclass={'test': PyTest},
)

24 changes: 24 additions & 0 deletions tests/test_lib.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from __future__ import with_statement
import pytest

from ascii_graph import Pyasciigraph

class TestLib(object):

def test_unsorted_default_params(self):
test = [('long_label', 423), ('sl', 1234), ('line3', 531), ('line4', 200), ('line5', 834)]
graph = Pyasciigraph()
res = graph.graph('test print', test)
expected = [
'test print',
u'###############################################################################',
u'████████████████████ 423 long_label',
u'█████████████████████████████████████████████████████████████ 1234 sl ',
u'██████████████████████████ 531 line3 ',
u'█████████ 200 line4 ',
u'█████████████████████████████████████████ 834 line5 ',
]
assert res == expected

0 comments on commit bd51630

Please sign in to comment.