Best Python code snippet using pyatom_python
bs.py
Source:bs.py
1import esc2import esccmd3import escio4from escutil import AssertEQ, AssertScreenCharsInRectEqual, GetCursorPosition, GetScreenSize, knownBug5from esctypes import Point, Rect6class BSTests(object):7 def test_BS_Basic(self):8 esccmd.CUP(Point(3, 3))9 escio.Write(esc.BS)10 AssertEQ(GetCursorPosition(), Point(2, 3))11 def test_BS_NoWrapByDefault(self):12 esccmd.CUP(Point(1, 3))13 escio.Write(esc.BS)14 AssertEQ(GetCursorPosition(), Point(1, 3))15 def test_BS_WrapsInWraparoundMode(self):16 esccmd.DECSET(esccmd.DECAWM)17 esccmd.DECSET(esccmd.ReverseWraparound)18 esccmd.CUP(Point(1, 3))19 escio.Write(esc.BS)20 size = GetScreenSize()21 AssertEQ(GetCursorPosition(), Point(size.width(), 2))22 def test_BS_ReverseWrapRequiresDECAWM(self):23 esccmd.DECRESET(esccmd.DECAWM)24 esccmd.DECSET(esccmd.ReverseWraparound)25 esccmd.CUP(Point(1, 3))26 escio.Write(esc.BS)27 AssertEQ(GetCursorPosition(), Point(1, 3))28 esccmd.DECSET(esccmd.DECAWM)29 esccmd.DECRESET(esccmd.ReverseWraparound)30 esccmd.CUP(Point(1, 3))31 escio.Write(esc.BS)32 AssertEQ(GetCursorPosition(), Point(1, 3))33 def test_BS_ReverseWrapWithLeftRight(self):34 esccmd.DECSET(esccmd.DECAWM)35 esccmd.DECSET(esccmd.ReverseWraparound)36 esccmd.DECSET(esccmd.DECLRMM)37 esccmd.DECSLRM(5, 10)38 esccmd.CUP(Point(5, 3))39 escio.Write(esc.BS)40 AssertEQ(GetCursorPosition(), Point(10, 2))41 def test_BS_ReversewrapFromLeftEdgeToRightMargin(self):42 """If cursor starts at left edge of screen, left of left margin, backspace43 takes it to the right margin."""44 esccmd.DECSET(esccmd.DECAWM)45 esccmd.DECSET(esccmd.ReverseWraparound)46 esccmd.DECSET(esccmd.DECLRMM)47 esccmd.DECSLRM(5, 10)48 esccmd.CUP(Point(1, 3))49 escio.Write(esc.BS)50 AssertEQ(GetCursorPosition(), Point(10, 2))51 @knownBug(terminal="xterm",52 reason="BS wraps past top margin. Bad idea in my opinion, but there is no standard for reverse wrap.")53 def test_BS_ReverseWrapWontPassTop(self):54 esccmd.DECSET(esccmd.DECAWM)55 esccmd.DECSET(esccmd.ReverseWraparound)56 esccmd.DECSTBM(2, 5)57 esccmd.CUP(Point(1, 2))58 escio.Write(esc.BS)59 AssertEQ(GetCursorPosition(), Point(1, 2))60 def test_BS_StopsAtLeftMargin(self):61 esccmd.DECSET(esccmd.DECLRMM)62 esccmd.DECSLRM(5, 10)63 esccmd.CUP(Point(5, 1))64 escio.Write(esc.BS)65 esccmd.DECRESET(esccmd.DECLRMM)66 AssertEQ(GetCursorPosition(), Point(5, 1))67 def test_BS_MovesLeftWhenLeftOfLeftMargin(self):68 esccmd.DECSET(esccmd.DECLRMM)69 esccmd.DECSLRM(5, 10)70 esccmd.CUP(Point(4, 1))71 escio.Write(esc.BS)72 esccmd.DECRESET(esccmd.DECLRMM)73 AssertEQ(GetCursorPosition(), Point(3, 1))74 def test_BS_StopsAtOrigin(self):75 esccmd.CUP(Point(1, 1))76 escio.Write(esc.BS)77 AssertEQ(GetCursorPosition(), Point(1, 1))78 def test_BS_CursorStartsInDoWrapPosition(self):79 """Cursor is right of right edge of screen."""80 size = GetScreenSize()81 esccmd.CUP(Point(size.width() - 1, 1))82 escio.Write("ab")83 escio.Write(esc.BS)84 escio.Write("X")85 AssertScreenCharsInRectEqual(Rect(size.width() - 1, 1, size.width(), 1),...
hvp.py
Source:hvp.py
1import esccmd2import escio3from escutil import AssertEQ, AssertScreenCharsInRectEqual, GetCursorPosition, GetScreenSize, knownBug4from esctypes import Point, Rect5class HVPTests(object):6 def test_HVP_DefaultParams(self):7 """With no params, HVP moves to 1,1."""8 esccmd.HVP(Point(6, 3))9 position = GetCursorPosition()10 AssertEQ(position.x(), 6)11 AssertEQ(position.y(), 3)12 esccmd.HVP()13 position = GetCursorPosition()14 AssertEQ(position.x(), 1)15 AssertEQ(position.y(), 1)16 def test_HVP_RowOnly(self):17 """Default column is 1."""18 esccmd.HVP(Point(6, 3))19 position = GetCursorPosition()20 AssertEQ(position.x(), 6)21 AssertEQ(position.y(), 3)22 esccmd.HVP(row=2)23 position = GetCursorPosition()24 AssertEQ(position.x(), 1)25 AssertEQ(position.y(), 2)26 def test_HVP_ColumnOnly(self):27 """Default row is 1."""28 esccmd.HVP(Point(6, 3))29 position = GetCursorPosition()30 AssertEQ(position.x(), 6)31 AssertEQ(position.y(), 3)32 esccmd.HVP(col=2)33 position = GetCursorPosition()34 AssertEQ(position.x(), 2)35 AssertEQ(position.y(), 1)36 def test_HVP_ZeroIsTreatedAsOne(self):37 """Zero args are treated as 1."""38 esccmd.HVP(Point(6, 3))39 esccmd.HVP(col=0, row=0)40 position = GetCursorPosition()41 AssertEQ(position.x(), 1)42 AssertEQ(position.y(), 1)43 def test_HVP_OutOfBoundsParams(self):44 """With overly large parameters, HVP moves as far as possible down and right."""45 size = GetScreenSize()46 esccmd.HVP(Point(size.width() + 10, size.height() + 10))47 position = GetCursorPosition()48 AssertEQ(position.x(), size.width())49 AssertEQ(position.y(), size.height())50 def test_HVP_RespectsOriginMode(self):51 """HVP is relative to margins in origin mode."""52 # Set a scroll region.53 esccmd.DECSTBM(6, 11)54 esccmd.DECSET(esccmd.DECLRMM)55 esccmd.DECSLRM(5, 10)56 # Move to center of region57 esccmd.HVP(Point(7, 9))58 position = GetCursorPosition()59 AssertEQ(position.x(), 7)60 AssertEQ(position.y(), 9)61 # Turn on origin mode.62 esccmd.DECSET(esccmd.DECOM)63 # Move to top-left64 esccmd.HVP(Point(1, 1))65 # Check relative position while still in origin mode.66 position = GetCursorPosition()67 AssertEQ(position.x(), 1)68 AssertEQ(position.y(), 1)69 escio.Write("X")70 # Turn off origin mode. This moves the cursor.71 esccmd.DECRESET(esccmd.DECOM)72 # Turn off scroll regions so checksum can work.73 esccmd.DECSTBM()74 esccmd.DECRESET(esccmd.DECLRMM)75 # Make sure there's an X at 5,676 AssertScreenCharsInRectEqual(Rect(5, 6, 5, 6),...
cup.py
Source:cup.py
1import esccmd2import escio3from escutil import AssertEQ, AssertScreenCharsInRectEqual, GetCursorPosition, GetScreenSize, knownBug4from esctypes import Point, Rect5class CUPTests(object):6 def test_CUP_DefaultParams(self):7 """With no params, CUP moves to 1,1."""8 esccmd.CUP(Point(6, 3))9 position = GetCursorPosition()10 AssertEQ(position.x(), 6)11 AssertEQ(position.y(), 3)12 esccmd.CUP()13 position = GetCursorPosition()14 AssertEQ(position.x(), 1)15 AssertEQ(position.y(), 1)16 def test_CUP_RowOnly(self):17 """Default column is 1."""18 esccmd.CUP(Point(6, 3))19 position = GetCursorPosition()20 AssertEQ(position.x(), 6)21 AssertEQ(position.y(), 3)22 esccmd.CUP(row=2)23 position = GetCursorPosition()24 AssertEQ(position.x(), 1)25 AssertEQ(position.y(), 2)26 def test_CUP_ColumnOnly(self):27 """Default row is 1."""28 esccmd.CUP(Point(6, 3))29 position = GetCursorPosition()30 AssertEQ(position.x(), 6)31 AssertEQ(position.y(), 3)32 esccmd.CUP(col=2)33 position = GetCursorPosition()34 AssertEQ(position.x(), 2)35 AssertEQ(position.y(), 1)36 def test_CUP_ZeroIsTreatedAsOne(self):37 """Zero args are treated as 1."""38 esccmd.CUP(Point(6, 3))39 esccmd.CUP(col=0, row=0)40 position = GetCursorPosition()41 AssertEQ(position.x(), 1)42 AssertEQ(position.y(), 1)43 def test_CUP_OutOfBoundsParams(self):44 """With overly large parameters, CUP moves as far as possible down and right."""45 size = GetScreenSize()46 esccmd.CUP(Point(size.width() + 10, size.height() + 10))47 position = GetCursorPosition()48 AssertEQ(position.x(), size.width())49 AssertEQ(position.y(), size.height())50 def test_CUP_RespectsOriginMode(self):51 """CUP is relative to margins in origin mode."""52 # Set a scroll region.53 esccmd.DECSTBM(6, 11)54 esccmd.DECSET(esccmd.DECLRMM)55 esccmd.DECSLRM(5, 10)56 # Move to center of region57 esccmd.CUP(Point(7, 9))58 position = GetCursorPosition()59 AssertEQ(position.x(), 7)60 AssertEQ(position.y(), 9)61 # Turn on origin mode.62 esccmd.DECSET(esccmd.DECOM)63 # Move to top-left64 esccmd.CUP(Point(1, 1))65 # Check relative position while still in origin mode.66 position = GetCursorPosition()67 AssertEQ(position.x(), 1)68 AssertEQ(position.y(), 1)69 escio.Write("X")70 # Turn off origin mode. This moves the cursor.71 esccmd.DECRESET(esccmd.DECOM)72 # Turn off scroll regions so checksum can work.73 esccmd.DECSTBM()74 esccmd.DECRESET(esccmd.DECLRMM)75 # Make sure there's an X at 5,676 AssertScreenCharsInRectEqual(Rect(5, 6, 5, 6),...
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!!