diff --git a/www/tests/brython_test_utils/__init__.py b/www/tests/brython_test_utils/__init__.py index 024379915..5683a8768 100644 --- a/www/tests/brython_test_utils/__init__.py +++ b/www/tests/brython_test_utils/__init__.py @@ -47,6 +47,399 @@ def discover_brython_test_modules(): ("test_types.py", "types") ])] +# FIXME : from test.regrtest import STDTEST as CPYTHON_STDTESTS +CPYTHON_STDTESTS = [ + 'test_grammar', + 'test_opcodes', + 'test_dict', + 'test_builtin', + 'test_exceptions', + 'test_types', + 'test_unittest', + 'test_doctest', + 'test_doctest2', + 'test_support' +] + +def discover_cpython_test_modules(): + # TODO: Test discovery based on file system contents + CPYTHON_TESTS = [ + 'test___all__', + 'test___future__', + 'test__locale', + 'test__osx_support', + 'test_abc', + 'test_abstract_numbers', + 'test_aifc', + 'test_argparse', + 'test_array', + 'test_ast', + 'test_asynchat', + 'test_asyncore', + 'test_atexit', + 'test_audioop', + 'test_augassign', + 'test_base64', + 'test_bigaddrspace', + 'test_bigmem', + 'test_binascii', + 'test_binhex', + 'test_binop', + 'test_bisect', + 'test_bool', + 'test_buffer', + 'test_bufio', +# 'test_builtin', + 'test_bytes', + 'test_bz2', + 'test_calendar', + 'test_call', + 'test_capi', + 'test_cgi', + 'test_cgitb', + 'test_charmapcodec', + 'test_class', + 'test_cmath', + 'test_cmd', + 'test_cmd_line', + 'test_cmd_line_script', + 'test_code', + 'test_code_module', + 'test_codeccallbacks', + 'test_codecencodings_cn', + 'test_codecencodings_hk', + 'test_codecencodings_iso2022', + 'test_codecencodings_jp', + 'test_codecencodings_kr', + 'test_codecencodings_tw', + 'test_codecmaps_cn', + 'test_codecmaps_hk', + 'test_codecmaps_jp', + 'test_codecmaps_kr', + 'test_codecmaps_tw', + 'test_codecs', + 'test_codeop', + 'test_coding', + 'test_collections', + 'test_colorsys', + 'test_compare', + 'test_compile', + 'test_compileall', + 'test_complex', + 'test_concurrent_futures', + 'test_configparser', + 'test_contains', + 'test_contextlib', + 'test_copy', + 'test_copyreg', + 'test_cprofile', + 'test_crashers', + 'test_crypt', + 'test_csv', + 'test_ctypes', + 'test_curses', + 'test_datetime', + 'test_dbm', + 'test_dbm_dumb', + 'test_dbm_gnu', + 'test_dbm_ndbm', + 'test_decimal', + 'test_decorators', + 'test_defaultdict', + 'test_deque', + 'test_descr', + 'test_descrtut', + 'test_devpoll', +# 'test_dict', + 'test_dictcomps', + 'test_dictviews', + 'test_difflib', + 'test_dis', + 'test_distutils', +# 'test_doctest', +# 'test_doctest2', + 'test_docxmlrpc', + 'test_dummy_thread', + 'test_dummy_threading', + 'test_dynamic', + 'test_enumerate', + 'test_eof', + 'test_epoll', + 'test_errno', + 'test_exception_variations', +# 'test_exceptions', + 'test_extcall', + 'test_faulthandler', + 'test_fcntl', + 'test_file', + 'test_file_eintr', + 'test_filecmp', + 'test_fileinput', + 'test_fileio', + 'test_float', + 'test_flufl', + 'test_fnmatch', + 'test_fork1', + 'test_format', + 'test_fractions', + 'test_frozen', + 'test_ftplib', + 'test_funcattrs', + 'test_functools', + 'test_future', + 'test_future3', + 'test_future4', + 'test_future5', + 'test_gc', + 'test_gdb', + 'test_generators', + 'test_genericpath', + 'test_genexps', + 'test_getargs2', + 'test_getopt', + 'test_gettext', + 'test_glob', + 'test_global', +# 'test_grammar', + 'test_grp', + 'test_gzip', + 'test_hash', + 'test_hashlib', + 'test_heapq', + 'test_hmac', + 'test_html', + 'test_htmlparser', + 'test_http_cookiejar', + 'test_http_cookies', + 'test_httplib', + 'test_httpservers', + 'test_idle', + 'test_imaplib', + 'test_imp', + 'test_import', + 'test_importhooks', + 'test_index', + 'test_inspect', + 'test_int', + 'test_int_literal', + 'test_io', + 'test_ioctl', + 'test_ipaddress', + 'test_isinstance', + 'test_iter', + 'test_iterlen', + 'test_itertools', + 'test_keywordonlyarg', + 'test_kqueue', + 'test_largefile', + 'test_lib2to3', + 'test_linecache', + 'test_list', + 'test_listcomps', + 'test_locale', + 'test_logging', + 'test_long', + 'test_longexp', + 'test_lzma', + 'test_macpath', + 'test_macurl2path', + 'test_mailbox', + 'test_mailcap', + 'test_marshal', + 'test_math', + 'test_memoryio', + 'test_memoryview', + 'test_metaclass', + 'test_mimetypes', + 'test_minidom', + 'test_mmap', + 'test_module', + 'test_modulefinder', + 'test_msilib', + 'test_multibytecodec', + 'test_multiprocessing', + 'test_namespace_pkgs', + 'test_netrc', + 'test_nis', + 'test_nntplib', + 'test_normalization', + 'test_ntpath', + 'test_numeric_tower', +# 'test_opcodes', + 'test_openpty', + 'test_operator', + 'test_optparse', + 'test_os', + 'test_ossaudiodev', + 'test_osx_env', + 'test_parser', + 'test_pdb', + 'test_peepholer', + 'test_pep247', + 'test_pep263', + 'test_pep277', + 'test_pep292', + 'test_pep3120', + 'test_pep3131', + 'test_pep3151', + 'test_pep352', + 'test_pep380', + 'test_pickle', + 'test_pickletools', + 'test_pipes', + 'test_pkg', + 'test_pkgimport', + 'test_pkgutil', + 'test_platform', + 'test_plistlib', + 'test_poll', + 'test_popen', + 'test_poplib', + 'test_posix', + 'test_posixpath', + 'test_pow', + 'test_pprint', + 'test_print', + 'test_profile', + 'test_property', + 'test_pstats', + 'test_pty', + 'test_pulldom', + 'test_pwd', + 'test_py_compile', + 'test_pyclbr', + 'test_pydoc', + 'test_pyexpat', + 'test_queue', + 'test_quopri', + 'test_raise', + 'test_random', + 'test_range', + 'test_re', + 'test_readline', + 'test_reprlib', + 'test_resource', + 'test_richcmp', + 'test_rlcompleter', + 'test_robotparser', + 'test_runpy', + 'test_sax', + 'test_sched', + 'test_scope', + 'test_select', + 'test_set', + 'test_setcomps', + 'test_shelve', + 'test_shlex', + 'test_shutil', + 'test_signal', + 'test_site', + 'test_slice', + 'test_smtpd', + 'test_smtplib', + 'test_smtpnet', + 'test_sndhdr', + 'test_socket', + 'test_socketserver', + 'test_sort', + 'test_sqlite', + 'test_ssl', + 'test_startfile', + 'test_stat', + 'test_strftime', + 'test_string', + 'test_stringprep', + 'test_strlit', + 'test_strptime', + 'test_strtod', + 'test_struct', + 'test_structmembers', + 'test_structseq', + 'test_subprocess', + 'test_sunau', + 'test_sundry', + 'test_super', +# 'test_support', + 'test_symtable', + 'test_syntax', + 'test_sys', + 'test_sys_setprofile', + 'test_sys_settrace', + 'test_sysconfig', + 'test_syslog', + 'test_tarfile', + 'test_tcl', + 'test_telnetlib', + 'test_tempfile', + 'test_textwrap', + 'test_thread', + 'test_threaded_import', + 'test_threadedtempfile', + 'test_threading', + 'test_threading_local', + 'test_threadsignals', + 'test_time', + 'test_timeit', + 'test_timeout', + 'test_tk', + 'test_tokenize', + 'test_tools', + 'test_trace', + 'test_traceback', + 'test_ttk_guionly', + 'test_ttk_textonly', + 'test_tuple', + 'test_typechecks', +# 'test_types', + 'test_ucn', + 'test_unary', + 'test_unicode', + 'test_unicode_file', + 'test_unicodedata', +# 'test_unittest', + 'test_univnewlines', + 'test_unpack', + 'test_unpack_ex', + 'test_urllib', + 'test_urllib2', + 'test_urllib2_localnet', + 'test_urllib2net', + 'test_urllib_response', + 'test_urllibnet', + 'test_urlparse', + 'test_userdict', + 'test_userlist', + 'test_userstring', + 'test_uu', + 'test_uuid', + 'test_venv', + 'test_wait3', + 'test_wait4', + 'test_warnings', + 'test_wave', + 'test_weakref', + 'test_weakset', + 'test_webbrowser', + 'test_winreg', + 'test_winsound', + 'test_with', + 'test_wsgiref', + 'test_xdrlib', + 'test_xml_dom_minicompat', + 'test_xml_etree', + 'test_xml_etree_c', + 'test_xmlrpc', + 'test_xmlrpc_net', + 'test_zipfile', + 'test_zipfile64', + 'test_zipimport', + 'test_zipimport_support', + 'test_zlib' + ] +# return CPYTHON_STDTESTS + sorted(CPYTHON_TESTS) + return [] + + def populate_testmod_input(elem, selected=None): """Build a multiple selection control including test modules """ diff --git a/www/tests/brython_test_utils/unittest.py b/www/tests/brython_test_utils/unittest.py index 73e7c6cdb..75391a0af 100644 --- a/www/tests/brython_test_utils/unittest.py +++ b/www/tests/brython_test_utils/unittest.py @@ -84,3 +84,35 @@ def load_brython_test_cases(): ) +class DeferredTestError(unittest.TestCase): + """Dummy test case used to keep track of failures at test module + import time. + """ + def __init__(self, exc): + """@param exc : Exception that will be raised in test case body. + """ + unittest.TestCase.__init__(self, 'runTests') + self.exc = exc + + def runTests(self): + raise self.exc + + +def load_cpython_test_cases(): + suite = unittest.TestSuite() + loader = unittest.defaultTestLoader + for modnm in utils.discover_cpython_test_modules(): + label = 'CPython : test.' + modnm + try: + __import__('test.' + modnm) + except ImportError as exc: + print('Could not import test module ' + modnm) + suite.addTest(NamedTestSuite(label, + [DeferredTestError(exc)])) + else: + print('Test module ' + modnm + ' imported ok') + suite.addTest(NamedTestSuite(label, + [loader.loadTestsFromName('test.' + modnm)])) + + return suite + diff --git a/www/tests/run_qunit.html b/www/tests/run_qunit.html index 62ebb1659..68e6b9a7d 100644 --- a/www/tests/run_qunit.html +++ b/www/tests/run_qunit.html @@ -71,9 +71,13 @@ # TODO: Arg values e.g. verbosity level ? result = test_utils.OneTimeTestResult() -def qunit_add_tests(suite): - module_name = getattr(suite, 'caption', None) or 'All tests' - _QUnit.module(module_name) +def qunit_add_tests(suite, caption=None): + # FIXME : Unpredictable module behavior in case of + # a) nested named suites + # b) test cases not wrapped by named test suite + module_name = getattr(suite, 'caption', None) + if module_name is not None or caption is not None: + _QUnit.module(module_name) pend = [] for test in suite: if isinstance(test, unittest.BaseTestSuite): @@ -81,11 +85,13 @@ else: _QUnit.test(test.shortDescription(), window.qunit_unittest_wrapper(test, result)) - for suite in pend: - qunit_add_tests(suite) + for s in pend: + # FIXME: What about class-level and module level setup/tearDown ? + qunit_add_tests(s, module_name) qunit_add_tests(test_utils.load_brython_test_cases()) +qunit_add_tests(test_utils.load_cpython_test_cases())