def test_info(): """ Tests output of running without parameters """ io = support.CapturingIo() rc = main.commandline(args=(), io=io) assert rc == 0 assert io.message.startswith('Flexirest')
def test_full_rtf_writing(): """ Full run of the `rtf` (Microsoft Rich Text) writer. """ io = support.CapturingIo() io.source = support.get_utf8_fixture() rc = main.commandline(['rtf', '--lang=sv'], io) # XXX Only sanity check yet. assert_equals(rc, 0)
def test_infile_and_outfile(): """ Tests the <infile> <outfile> syntax. """ with TempDirectory('fr-in-out') as td: td.put('infile.rst', support.MINIMAL_FIXTURE) rc = main.commandline(['html', td.newpath('infile.rst'), td.newpath('outfile.html')], io=support.NullIo()) assert rc == 0 assert ('<title>A minimal fixture</title>' in td.open('outfile.html', 'r').read() )
def test_infile_in_home(): """ Enshures that the `--infile` option property expands home directories (`~`). """ try: infile_in_home() io = support.CapturingIo() rc = main.commandline(['html', INFILE_IN_HOME], io) assert rc == 0 finally: support.clean_gc_testfiles()
def test_w_infile(): """ Tests using a named infile. """ try: simple_infile_creator() io = support.CapturingIo() rc = main.commandline(['html', SIMPLE_INFILE_PATH], io) assert rc == 0 assert '<title>A minimal fixture</title>' in io.result finally: support.clean_gc_testfiles()
def test_template_in_home(): """ Tests that templates in the users home directories are correctly opened. """ try: tmpl_in_home_creator() io = support.CapturingIo() rc = main.commandline(['html', '--template=%s' % TMPL_IN_HOME], io=io) assert 0 == rc finally: support.clean_gc_testfiles()
def test_w_outfile(): """ Tests the `--outfile` commandline option. """ try: io = support.CapturingIo() rc = main.commandline(['html', '--outfile=%s' % SIMPLE_OUTFILE], io=support.CapturingIo()) assert_equals(rc, 0) assert_true('<title>A minimal fixture</title>' in open(SIMPLE_OUTFILE, 'r').read()) finally: os.unlink(SIMPLE_OUTFILE)
def test_template_basic(): """ Make a minimal template and see that `docutils` content gets correctly applied to it. """ try: tmpl_basic_creator() io = support.CapturingIo() main._import = lambda m, r: imp.new_module(m) rc = main.commandline(['pseudoxml', '--template=%s' % BASIC_TMPL], io=io) assert 'the_template' in io.result assert 'title="A minimal fixture"' in io.result finally: supp.clean_gc_testfiles()
def test_full_xelatex_writing(): """ Full run of the `xelatex` (XeLaTeX) pseudo-writer. """ try: setup_latex_dir('fr-xelatex-full-') io = support.CapturingIo() io.source = support.get_utf8_fixture() rc = main.commandline(['xelatex', '--lang=sv', '--template=%s' % latex_tmp('template.tex')], io=io) if rc == errno.ENOSYS: pytest.skip('xelatex not present on system') check_pdf_result(rc, io) finally: teardown_latex_dir()
def test_full_role(): """ Try out a role that actually does something. """ try: tmpl_full_role_creator() io = support.CapturingIo( source = StringIO(textwrap.dedent(""" Some text :foo:`Some test text` after """)) ) rolesmod = imp.new_module('roles') rolesmod.role_foo = role_foo main._import = lambda m, r: rolesmod rc = main.commandline(['pseudoxml', '--template=%s' % ROLE_TMPL], io=io) assert_true('ROLESTART_Some test text_ROLESTOP' in io.result) finally: support.clean_gc_testfiles()
def test_bad_writer_nice_error(): io = support.CapturingIo() rc = main.commandline(['bad_writer'], io=io) assert rc, errno.EINVAL assert (io.errlines == ["flexirest: 'bad_writer' is not a valid writer", ''])
def test_no_default_confmodule_noraise(): io = support.CapturingIo() io.source = support.get_minimal_fixture() main.commandline([], io=io)
def test_explicit_confmodule_not_found_raises(): with pytest.raises(ImportError): main.commandline(['latex', '--config=notamodule'], io=support.NullIo())
def test_dump_parts(): io = support.CapturingIo() io.source = support.get_minimal_fixture() rc = main.commandline(['latex', '--dump-parts'], io=io) # XXX sanity check only assert io.msglines[0].startswith("Parts created by the docutils")
def check_status(variant): io = support.CapturingIo() rc = main.commandline(args=[variant], io=io) assert rc == 0 assert io.message.startswith(expected_status_start)
def check_version(variant): io = support.CapturingIo() retc = main.commandline(args=[variant,], io=io) assert retc == 0 assert io.msglines == [flexirest.VERSION, '']