def test_doc(self): with capture_stdin_and_stdout(): self.command([ '-r', 'breadth', '-i', Global.get_filename("doc/index.html"), 'chain', '-t', 'http://www.w3.org/1999/xhtml', '-n', 'error' ]) breadth = sys.stdout.buffer.getvalue() with capture_stdin_and_stdout(): self.command([ '-r', 'depth', '-i', Global.get_filename("doc/index.html"), 'chain', '-t', 'http://www.w3.org/1999/xhtml', '-n', 'error' ]) depth = sys.stdout.buffer.getvalue() self.assertXmlEqual(breadth, depth)
def do_run_comment(self, order, next_script_mode): self.command([ '-r', order, '-s', next_script_mode, '-i', Global.get_filename("tests/core/data/xml/comment.xml"), 'chain', '-u', 'http://portonvictor.org/ns/trans/precedence-comment' ]) self.assertXmlEqual(sys.stdout.buffer.getvalue(), TestUtility.comment_output)
def test_avoid_infinite_loop(self): with capture_stdin_and_stdout(): ret = xmlboiler.command_line.command.main([ '-i', Global.get_filename("tests/core/data/xml/wrong.xml"), 'c', '-u', 'http://portonvictor.org/ns/trans/precedence-comment' ]) self.assertTrue(ret != 0) self.assertEqual(sys.stdout.buffer.getvalue().decode('utf-8'), "")
def test_nodownload(self): with capture_stdin_and_stdout(): self.command([ '-r', 'none', '-s', 'doc', '-p', 'http://portonvictor.org/ns/comment', '-i', Global.get_filename("tests/core/data/xml/comment.xml"), 'chain', '-u', 'http://portonvictor.org/ns/trans/precedence-comment' ]) self.assertXmlEqual(sys.stdout.buffer.getvalue(), TestUtility.comment_output)
def init_locale(lang=None): #locale.setlocale(locale.LC_ALL, '') # TODO: call from your app try: if lang is None: lang = locale.getlocale()[0][0:2] file = Global.get_resource_stream("res/messages_%s.mo" % lang) trans = gettext.GNUTranslations(file) except (ValueError, IOError): logging.debug("Locale not found. Using default messages") trans = gettext.NullTranslations() #trans.set_output_charset() # TODO return trans
def test_installed_packages(self): for installed in ['package', 'executable', 'both']: with self.subTest(installed=installed): with capture_stdin_and_stdout(): self.command([ '--software', installed, '-i', Global.get_filename("tests/core/data/xml/comment.xml"), 'chain', '-u', 'http://portonvictor.org/ns/trans/precedence-comment' ]) self.assertXmlEqual(sys.stdout.buffer.getvalue(), TestUtility.comment_output)
def test_syntax(self): for next_script_mode in ['doc']: for order in ['breadth', 'depth']: with self.subTest(next_script=next_script_mode, order=order): with capture_stdin_and_stdout(): self.command([ '-r', order, '-s', next_script_mode, '-i', Global.get_filename( "tests/core/data/xml/syntax.xml"), 'chain', '-t', 'http://www.w3.org/1999/xhtml', '-n', 'error' ]) # sys.stdout.buffer.write(b'<pre>...') self.assertRegex( sys.stdout.buffer.getvalue().decode('utf-8'), r'<pre>')
from .regular import RegularCommandRunner class FirejailCommandRunner(object): """ This does not isolate from X11 on Linux because of abstract sockets! """ def __init__(self, netfilter, timeout=None, timeout2=None): self.base = RegularCommandRunner(timeout=timeout, timeout2=timeout2) # TODO: Use provider self.netfilter = netfilter def run_pipe(self, args, input): """ This does not isolate from X11 on Linux because of abstract sockets! TODO: --rlimit-* --timeout """ fj = ['firejail', '--shell=none', '-c', '--quiet', '--caps.drop=all', '--disable-mnt', '--protocol=unix,inet', # TODO: Also enable IPv6 (after creating the firewall) '--netfilter=' + self.netfilter, '--hostname=none', '--machine-id', '--name=xmlboiler', '--nogroups', '--private', '--private-tmp', '--seccomp', '--nodvd', '--nonewprivs', '--nosound', '--notv', '--novideo', #'--x11=none', '--blacklist=/home', '--blacklist=/root'] return self.base.run_pipe(fj + args, input) firejail_provider = providers.Factory(FirejailCommandRunner, netfilter=Global.get_filename('core/data/mynolocal.net'), timeout=None, timeout2=None)
def setUp(self): self.v = setup_with_context_manager( self, change_dir(Global.get_filename("tests/core/data/xml")))
class Providers(containers.DeclarativeContainer): interpreters_factory = providers.ThreadLocalSingleton( Interpeters, execution_context=execution_context_builders.Contexts. execution_context, graph=Global.load_rdf('core/data/interpreters.ttl'))