text_lint.linter.states.assertion.AssertionState

class text_lint.linter.states.assertion.AssertionState(linter: Linter)[Quellcode]

Bases: StateBase

State for assertion operations.

__init__(linter: Linter) None[Quellcode]

Initialize AssertionState instances.

Parameter:

linter (Linter) – The linter instance being encapsulated.

fail(expected: str) None[Quellcode]

Raise an exception indicating this operation has failed.

Parameter:

expected (str) – The value the assertion operation was expecting.

loop(assertions: List[AssertionBase], count: int) None[Quellcode]

Start a looped sequence of assertions after the current operation.

Parameter:
  • assertions (List[AssertionBase]) – A list of assertion operations to loop over.

  • count (int) – The number of times to repeat these operations.

next() str[Quellcode]

Read the next line from the text file.

Rückgabe:

The next line from the text file.

Rückgabetyp:

str

rewind() str[Quellcode]

Rewind the text file so another assertion can try matching.

Rückgabe:

The previous line the text file has been rewound to.

Raises:

AssertionLogicError (if invoked twice in a row)

Rückgabetyp:

str

save(matches: Match[str] | Sequence[Match[str]]) None[Quellcode]

Save the given regex match group(s).

Parameter:

matches (Match[str] | Sequence[Match[str]]) – A list or individual regex match object to save.