Skip to content

Enable Travis CI build #6

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

Merged
merged 3 commits into from
Jan 28, 2016
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
language: python

python:
- "2.6"
- "2.7"

# command to install dependencies
install: pip install -r dev-requirements.txt

before_script:
- "export DISPLAY=:99.0"
- "sh -e /etc/init.d/xvfb start"
- sleep 3 # give xvfb some time to start

# command to run tests
script: nosetests --with-xunit --with-coverage --cover-html --cover-html-dir=Coverage_report --verbosity=3 test/testall.py

after_success:
- codecov
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
[![Build Status](https://travis-ci.org/python-xlib/python-xlib.svg?branch=master)](https://travis-ci.org/python-xlib/python-xlib)

# The Python X Library

### Copyright
Expand All @@ -8,12 +10,13 @@ The main part of the code is

Some contributed code is copyrighted by [the contributors](https://github.com/python-xlib/python-xlib/graphs/contributors), in these cases that is indicated in the source files in question.

The Python X Library is released under LGPL v2.1 or later, see the file LICENSE for details.
The Python X Library is released under LGPL v2.1 or later (since 2016), see the file LICENSE for details.
0.15rc1 and before were released under GPL v2.

### Requirements

The Python X Library requires Python 1.5.2 or newer. It has been
tested to various extents with Python 1.5.2 and 2.0 through 2.6.
tested to various extents with Python 1.5.2 and 2.0 through 2.7.


### Installation
Expand Down
2 changes: 2 additions & 0 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
coverage
codecov
68 changes: 68 additions & 0 deletions test/testall.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#!/usr/bin/env python

from __future__ import print_function
import sys
import os
import unittest
import struct

import coverage

testfolder = os.path.abspath(os.path.dirname(__file__))
package_root = os.path.abspath(os.path.join(testfolder, ".."))
sys.path.append(package_root)

# needs to be called before importing the modules
cov = coverage.coverage(branch = True, omit = os.path.join(package_root, 'examples', '*.py'))
cov.start()

from Xlib.protocol import request, rq, event
import Xlib.protocol.event

def is_big_endian():
"Check endianess (return True on big-endian system)"
return struct.unpack('BB', struct.pack('H', 0x0100))[0] != 0


def run_tests():
"Run all suitable tests"

if is_big_endian():
excludes = ['test_events_le', 'test_requests_le', ]
else:
excludes = ['test_events_be', 'test_requests_be', ]

suite = unittest.TestSuite()

sys.path.append(testfolder)

for root, dirs, files in os.walk(testfolder):
test_modules = [
file.replace('.py', '') for file in files if
file.startswith('test_') and
file.endswith('.py')]

test_modules = [mod for mod in test_modules if mod.lower() not in excludes]
print('test_modules:')
print(test_modules)
for mod in test_modules:

imported_mod = __import__(mod, globals(), locals())

suite.addTests(
unittest.defaultTestLoader.loadTestsFromModule(imported_mod))

unittest.TextTestRunner(verbosity=3).run(suite)
cov.stop()
#print(cov.analysis())
print(cov.report())
cov.html_report(
directory = os.path.join(package_root, "Coverage_report"),
omit = [os.path.join(package_root, 'examples', '*.py'),
os.path.join(package_root, 'utils', '*.py'),
os.path.join(package_root, 'test', '*.py'), ]
)


if __name__ == '__main__':
run_tests()