def test_converters(): assert (r'/^ecma \d regex$/im' == utilities.convert_python_regex_to_ecma( *utilities.convert_ecma_regex_to_python(r'/^ecma \d regex$/im'))) result = utilities.convert_ecma_regex_to_python( utilities.convert_python_regex_to_ecma(r'^some \w python regex$', [re.I])) assert r'^some \w python regex$' == result.regex assert [re.I] == result.flags
def test_convert_python_regex_to_ecma(): assert ('/^some regex$/' == utilities.convert_python_regex_to_ecma( r'^some regex$')) assert ('/^some regex$/' == utilities.convert_python_regex_to_ecma( r'^some regex$', [])) assert (r'/pattern \d+/i' == utilities.convert_python_regex_to_ecma( r'pattern \d+', [re.I])) assert (r'/pattern \d+/m' == utilities.convert_python_regex_to_ecma( r'pattern \d+', [re.M])) assert (r'/pattern \d+/im' == utilities.convert_python_regex_to_ecma( r'pattern \d+', [re.I, re.M])) assert ('/ecma pattern$/' == utilities.convert_python_regex_to_ecma( '/ecma pattern$/')) assert ('/ecma pattern$/im' == utilities.convert_python_regex_to_ecma( '/ecma pattern$/im')) assert ('/ecma pattern$/wrong' == utilities.convert_python_regex_to_ecma( '/ecma pattern$/wrong')) assert ('/ecma pattern$/m' == utilities.convert_python_regex_to_ecma( '/ecma pattern$/m', [re.M]))
def test_converters(): assert ( '/^ecma \d regex$/im' == utilities.convert_python_regex_to_ecma( *utilities.convert_ecma_regex_to_python('/^ecma \d regex$/im')) ) result = utilities.convert_ecma_regex_to_python( utilities.convert_python_regex_to_ecma( '^some \w python regex$', [re.I])) assert '^some \w python regex$' == result.regex assert [re.I] == result.flags
def test_convert_python_regex_to_ecma(): assert ( '/^some regex$/' == utilities.convert_python_regex_to_ecma('^some regex$') ) assert ( '/^some regex$/' == utilities.convert_python_regex_to_ecma('^some regex$', []) ) assert ( '/pattern \d+/i' == utilities.convert_python_regex_to_ecma('pattern \d+', [re.I]) ) assert ( '/pattern \d+/m' == utilities.convert_python_regex_to_ecma('pattern \d+', [re.M]) ) assert ( '/pattern \d+/im' == utilities.convert_python_regex_to_ecma('pattern \d+', [re.I, re.M]) ) assert ( '/ecma pattern$/' == utilities.convert_python_regex_to_ecma('/ecma pattern$/') ) assert ( '/ecma pattern$/im' == utilities.convert_python_regex_to_ecma('/ecma pattern$/im') ) assert ( '/ecma pattern$/wrong' == utilities.convert_python_regex_to_ecma('/ecma pattern$/wrong') ) assert ( '/ecma pattern$/m' == utilities.convert_python_regex_to_ecma('/ecma pattern$/m', [re.M]) )