Skip to content

Commit

Permalink
Start adding tests
Browse files Browse the repository at this point in the history
  • Loading branch information
takluyver committed Mar 22, 2015
1 parent c419dd9 commit 57ed8cb
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 0 deletions.
Empty file added tests/__init__.py
Empty file.
4 changes: 4 additions & 0 deletions tests/samples/module1-pkg.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[metadata]
author=Sir Robin
author-email=robin@camelot.uk
home-page=http://github.com/sirrobin/module1
3 changes: 3 additions & 0 deletions tests/samples/module1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"""Example module"""

__version__ = '0.1'
4 changes: 4 additions & 0 deletions tests/samples/package1-pkg.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[metadata]
author=Sir Robin
author-email=robin@camelot.uk
home-page=http://github.com/sirrobin/package1
3 changes: 3 additions & 0 deletions tests/samples/package1/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"""A sample package"""

__version__ = '0.1'
1 change: 1 addition & 0 deletions tests/samples/package1/foo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
a = 1
28 changes: 28 additions & 0 deletions tests/test_importable.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import os
from pathlib import Path
from unittest import TestCase

from flit import Importable

class ImportableTests(TestCase):
def setUp(self):
self.orig_working_dir = os.getcwd()
samples_dir = os.path.join(os.path.dirname(__file__), 'samples')
os.chdir(samples_dir)

def tearDown(self):
os.chdir(self.orig_working_dir)

def test_package_importable(self):
i = Importable('package1')
i.check()
assert i.path == Path('package1')

def test_module_importable(self):
i = Importable('module1')
i.check()
assert i.path == Path('module1.py')

def test_missing_name(self):
with self.assertRaises(ValueError):
i = Importable('doesnt_exist')

0 comments on commit 57ed8cb

Please sign in to comment.