Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@pytest.mark.parametrize(argnames="quote_type", argvalues=QuoteTypes.all)
def test_initial_doesnt_matter(quote_type):
code = random.choice(["'abra'", '"bobro"', "'''abra'''", '"""bobro"""'])
assert get_quote_type(set_quote_type(code, quote_type)) == quote_type
def get_quote_type(self):
assert self.toknum is token.STRING
for qt in QuoteTypes.all:
if self.tokval[: len(qt)] == qt and self.tokval[-len(qt) :] == qt:
return qt
if self.is_legacy_unicode_string():
for qt in QuoteTypes.all:
if self.tokval[1 : len(qt) + 1] == qt and self.tokval[-len(qt) :] == qt:
return qt
raise FlyntException(f"Can't determine quote type of the string {self.tokval}.")
def get_quote_type(self):
assert self.toknum is token.STRING
for qt in QuoteTypes.all:
if self.tokval[: len(qt)] == qt and self.tokval[-len(qt) :] == qt:
return qt
if self.is_legacy_unicode_string():
for qt in QuoteTypes.all:
if self.tokval[1 : len(qt) + 1] == qt and self.tokval[-len(qt) :] == qt:
return qt
raise FlyntException(f"Can't determine quote type of the string {self.tokval}.")