[go: up one dir, main page]

Skip to content

Commit

Permalink
Add CLI tests for HTML and package generators
Browse files Browse the repository at this point in the history
  • Loading branch information
jvanstraten committed Sep 2, 2019
1 parent 1657467 commit e4e67fe
Showing 1 changed file with 66 additions and 0 deletions.
66 changes: 66 additions & 0 deletions tests/cli/test_generators.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
"""Runs basic tests for all `vhdmmio`'s generators."""

import os
from os.path import join as pjoin
import tempfile
from unittest import TestCase
from vhdmmio import run_cli

class TestVhdlPaths(TestCase):
"""Runs basic tests for all `vhdmmio`'s generators."""

@staticmethod
def _list_files(base):
"""Lists the files in the given directory."""
return sorted((
os.path.relpath(pjoin(directory, filename), base)
for directory, _, filenames in os.walk(base)
for filename in filenames))

def test_package_default(self):
"""test package output in default directory"""
with tempfile.TemporaryDirectory() as base:
cwd = os.getcwd()
try:
os.chdir(base)
self.assertEqual(run_cli(['-P']), 0)
finally:
os.chdir(cwd)
self.assertEqual(self._list_files(base), ['vhdmmio_pkg.gen.vhd'])

def test_package_custom(self):
"""test package output in specified directory"""
with tempfile.TemporaryDirectory() as base:
cwd = os.getcwd()
try:
os.chdir(base)
self.assertEqual(run_cli(['-P', 'a/b']), 0)
finally:
os.chdir(cwd)
self.assertEqual(self._list_files(base), ['a/b/vhdmmio_pkg.gen.vhd'])

def test_html_default(self):
"""test HTML output in default directory"""
with tempfile.TemporaryDirectory() as base:
cwd = os.getcwd()
try:
os.chdir(base)
self.assertEqual(run_cli(['-H']), 0)
finally:
os.chdir(cwd)
self.assertEqual(self._list_files(base), [
'vhdmmio-doc/index.html',
'vhdmmio-doc/style.css'])

def test_html_custom(self):
"""test HTML output in specified directory"""
with tempfile.TemporaryDirectory() as base:
cwd = os.getcwd()
try:
os.chdir(base)
self.assertEqual(run_cli(['-H', 'a/b']), 0)
finally:
os.chdir(cwd)
self.assertEqual(self._list_files(base), [
'a/b/index.html',
'a/b/style.css'])

0 comments on commit e4e67fe

Please sign in to comment.