Best Python code snippet using molecule_python
tox.py
Source: tox.py
...18 env_overrides = {"PY_COLORS": "0"}19 tox_cfg = run_or_fail(["tox", "--showconfig"], env_overrides=env_overrides).stdout20 # workaround for https://github.com/tox-dev/tox/issues/203021 # we remove all lines starting with .tox from output22 tox_cfg = re.sub(r"\.tox.*\n?", "", strip_ansi_escape(tox_cfg), re.MULTILINE)23 # now tox_cfg should have a valid ini content24 cp.read_string(tox_cfg)25 for section in cp.sections():26 if section.startswith("testenv:"):27 _, env_name = section.split(":")28 # we ignore hidden envs like implicit .pkg:29 if not env_name.startswith("."):30 actions.append(31 Action(32 name=env_name,33 tool=self,34 description=cp[section]["description"],35 args=[env_name],36 )...
strip-osc.py
Source: strip-osc.py
2# terminal output. Helping @Abraham-Alfred with his Honour's project3# https://en.wikipedia.org/wiki/ANSI_escape_code#OSC_(Operating_System_Command)_sequences4# Adapted from https://stackoverflow.com/a/71775190/120699685import pyte # terminal emulator: render terminal output to visible characters6def strip_ansi_escape(f_in: str, f_out: str) -> str:7 print(f'parsing {repr(f_in)}...')8 9 pyte_screen = pyte.Screen(80, 24)10 pyte_stream = pyte.ByteStream(pyte_screen)11 with open(f_in, 'rb') as f:12 pyte_stream.feed(f.read())13 14 with open(f_out, 'w') as f:15 for line in pyte_screen.display:16 f.write(line.rstrip() + '\n')17 byte_pos = f.tell()18 19 print(f'bytes written to {repr(f_out)}: {byte_pos}')20 print(f'cursor: {pyte_screen.cursor.y}, {pyte_screen.cursor.x}')21 print(f'title: {pyte_screen.title}')22# Example23bytes_ = b''.join([24 b'$ cowsay hello\r\n', b'\x1b[?2004l', b'\r', b' _______\r\n',25 b'< hello >\r\n', b' -------\r\n', b' \\ ^__^\r\n',26 b' \\ (oo)\\_______\r\n', b' (__)\\ )\\/\\\r\n',27 b' ||----w |\r\n', b' || ||\r\n',28 b'\x1b]0;user@laptop1:/tmp\x1b\\', b'\x1b]7;file://laptop1/tmp\x1b\\', b'\x1b[?2004h$ ',29])30p = 'random-cowsay-encoded-file-ksdjnfkdjfskdsnjfkjsdsdkfnaldsm.txt'31with open(p, 'wb') as f:32 f.write(bytes_)...
test_string_tools.py
Source: test_string_tools.py
1import LexTools.string_tools as tools2import pytest3def test_strip_ansi_escape():4 ''' Unit tests for strip_ansi_escape '''5 test = 'ls\r\n\x1b[00m\x1b[01;31mexamplefile.zip\x1b[00m\r\n\x1b[01;31m'6 assert tools.strip_ansi_escape(test) == 'ls\r\nexamplefile.zip\r\n'7def test_extract_string():8 ''' Unit tests for extract_string '''9 assert tools.grep('this', 'Extract this') == 'this'10 assert tools.grep('t[a-z]*s', 'Extract this') == 'this'11def test_to_ordinal():12 ''' Unit tests for to_ordinal '''13 assert tools.to_ordinal(0) == '0th'14 assert tools.to_ordinal(1) == '1st'15 assert tools.to_ordinal(2) == '2nd'16 assert tools.to_ordinal(3) == '3rd'17 assert tools.to_ordinal(4) == '4th'18 assert tools.to_ordinal(11) == '11th'19 assert tools.to_ordinal(12) == '12th'20 assert tools.to_ordinal(13) == '13th'...
Check out the latest blogs from LambdaTest on this topic:
People love to watch, read and interact with quality content — especially video content. Whether it is sports, news, TV shows, or videos captured on smartphones, people crave digital content. The emergence of OTT platforms has already shaped the way people consume content. Viewers can now enjoy their favorite shows whenever they want rather than at pre-set times. Thus, the OTT platform’s concept of viewing anything, anytime, anywhere has hit the right chord.
When working on web automation with Selenium, I encountered scenarios where I needed to refresh pages from time to time. When does this happen? One scenario is that I needed to refresh the page to check that the data I expected to see was still available even after refreshing. Another possibility is to clear form data without going through each input individually.
Most test automation tools just do test execution automation. Without test design involved in the whole test automation process, the test cases remain ad hoc and detect only simple bugs. This solution is just automation without real testing. In addition, test execution automation is very inefficient.
I was once asked at a testing summit, “How do you manage a QA team using scrum?” After some consideration, I realized it would make a good article, so here I am. Understand that the idea behind developing software in a scrum environment is for development teams to self-organize.
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!