Layout, test command and regression traps for the Python repositories these bugs come from - sqlglot, python-docx, python-pptx, cantools and pygments. Open this once you know which repository you are in, before running any test.
Install
npx skillscat add gittensor-model-hub/spark-hermes/codebase-map Install via the SkillsCat registry.
The repositories
Find out which one you are in with one cheap call: ls /testbed. The source is either a top-level
package directory or under src/. Then read the matching section and nothing else.
Two questions are worth answering before you touch anything: where does the module in the issue live,
and which test file covers it. The second is what protects you from scoring zero, because the tests
kept for grading are drawn mostly from the file that covers the code you changed.
sqlglot
- Source:
sqlglot/at the top level. Tests:tests/. - The parts:
tokens.pyand the tokenizer,parser.py,generator.py,expressions(the AST node
classes — a module in some versions, a package in others),optimizer/with one module per rule
(qualify_columns,unnest_subqueries,pushdown_predicates,merge_subqueries,simplify,eliminate_*,annotate_types,scope),dialects/with one module per SQL dialect,transforms.py,planner.py,executor/. - Idioms that make mutations visible: an expression class declares
arg_types; a dialect nests its ownTokenizer,ParserandGenerator; parsers key off dicts likeFUNCTIONSandSTATEMENT_PARSERS;
generators off aTRANSFORMSdict and<node>_sqlmethods. Dialects are near-copies of one another,
so the same method in a sibling dialect is the reference for what the mutated one should say. - Trap:
tests/fixtures/holds.sqlgolden files (identity.sql,optimizer/*.sql) that the tests
read and compare against. They are test data. Never edit them — a failing fixture means your fix is
wrong, not that the fixture is. - Tests:
python -m pytest tests/test_optimizer.py -q. The optimizer file includes TPC-H and TPC-DS
cases and is slow; select a single test with-kwhile iterating and run the file once at the end.
python-docx
- Source:
src/docx/. Tests:tests/, mirroring the package (tests/oxml/,tests/text/,tests/parts/).features/is a separate acceptance suite, not pytest — ignore it. - The parts: the public objects in
document.py,table.py,text/paragraph.py,text/run.py,section.py,shape.py; the XML layer inoxml/(custom lxml element classes, declared with the
descriptors inoxml/xmlchemy.py, value types inoxml/simpletypes.py); packaging inopc/andparts/. - Where behaviour lives: a public method on a
docx/object usually delegates straight to aCT_*
element class inoxml/. If the public method looks right, the bug is one level down. - Trap, and it is the main way to score zero here: the pytest configuration sets
filterwarningstoerror. Any warning your change newly raises — a deprecation, a resource warning — is a test
failure across unrelated tests. Do not introduce a new warning, and do not silence one. - Tests:
python -m pytest tests/test_table.py -q, or the mirrored path for the module you touched.
python-pptx
- Source:
src/pptx/. Tests:tests/, mirroring the package.features/is behave, not pytest. - The parts:
presentation.py,package.py,shapes/,chart/,text/,table.py,util.py,
document properties underopc/, and the sameoxml/element-class layer as python-docx, with the
samexmlchemydescriptors. - Same trap:
filterwarningsiserror. A new warning fails unrelated tests. - Tests:
python -m pytest tests/test_<module>.py -qat the mirrored path.
cantools
- Source:
src/cantools/. Tests:tests/, with data files intests/files/. - The parts:
database/can/(database.py,message.py,signal.py,node.py,bus.py) anddatabase/can/formats/(dbc.py,kcd.py,sym.py,arxml/); the command line insubparsers/
(list.py,dump/,decode.py,convert.py,plot.py,monitor.py,generate_c_source.py). - Where behaviour lives: the subcommand modules print. Their tests compare exact stdout, so
whitespace, column order and line breaks are the contract — matching the expected output character for
character is the fix, not an approximation of it. - Note: the pytest configuration lives in
tox.iniand setsaddopts = -v, so runs are verbose by
default. Pass-qyourself to keep the output small. - Tests:
python -m pytest tests/test_list.py -q,tests/test_database.py(large, slow — use-k),tests/test_command_line.py,tests/test_convert.py.
pygments
- Source:
pygments/at the top level. Tests:tests/. - The parts:
lexer.py(Lexer,RegexLexer,DelegatingLexer,ExtendedRegexLexer, and the helpersbygroups,using,include,default),lexers/with one module per language family and the
generatedlexers/_mapping.py, plusformatters/,filters/,styles/,token.py,util.py. - Where behaviour lives: a lexer is mostly a
tokensdict of regex-to-token rules, and the mutation is
usually inside one rule or in a constructor. ADelegatingLexersubclass passes its two lexers up tosuper().__init__in a fixed order — root lexer, then language lexer — and swapping them is a classic
injected edit. - Trap, and it is the main way to score zero here: most of the suite is golden-file snapshot tests
generated bytests/conftest.pyfromtests/snippets/andtests/examplefiles/. A change to a shared
lexer or tolexer.pycan fail hundreds of them at once. The suite also offers a flag that rewrites
those golden files — never use it. It edits the tests and scores zero. - Tests:
python -m pytest tests/test_basic_api.py -qfor the core, and the snippet directory named
after the lexer alias you touched.python -m pytest tests/ -qis large; reach for it only with budget
left.
astroid
- Source:
astroid/at the top level. Tests:tests/, mostly flat (test_inference.py,test_nodes.py,test_builder.py,test_scoped_nodes.py,test_protocols.py,test_manager.py,test_modutils.py),
withtests/brain/for the brain modules andtests/testdata/for fixtures. - What it is: the AST and static-inference engine behind pylint. The parts:
nodes/(node_classes.py,scoped_nodes/,node_ng.py,as_string.py),brain/with onebrain_<library>.pyper third-party
package it models, plusbuilder.pyandrebuilder.py(source to AST),bases.py,protocols.py,inference_tip.py,manager.py,modutils.py,helpers.py,objects.py,arguments.py. - Idioms that make a mutation visible: inference is generator-based —
infer()and_infer()yield
results and yield theUninferablesentinel when they cannot decide. A mutation that turns ayield
into areturn, drops theUninferablebranch, or reverses a generator's order looks harmless and
breaks many tests. Node classes declare their children in_astroid_fields/_other_fields;
compare a node against its siblings in the same file. - Two traps here, and both cost the whole task. The pytest configuration sets
filterwarningstoerror, so any new warning fails unrelated tests. It also setsxfail_strict, which means a test
marked expected-to-fail that starts passing is a failure — so fixing more than the issue asks
for can break tests by making them succeed. Stay minimal here more than anywhere else. - Tests:
python -m pytest tests/test_inference.py -q, or the file matching the area you touched.
oauthlib
- Source:
oauthlib/at the top level. Tests:tests/, mirroring it exactly. - The parts:
common.py,uri_validate.py,signals.py, and three protocol trees —oauth1/,oauth2/(rfc6749/,rfc8628/) andopenid/. Insideoauth2/rfc6749/:grant_types/
(authorization_code,implicit,client_credentials,refresh_token,resource_owner_password_credentials, all onbase.py),clients/,endpoints/,tokens.py,parameters.py,errors.py,request_validator.py,utils.py. - Where behaviour lives: this is a protocol library, so the contract is exact strings — parameter names,
URL encoding, header spelling, error codes. The grant types are near-copies of each other on a shared
base, which makesbase.pyand the sibling grant the reference for a mutated one.errors.py
defines the error classes with their exacterrorslugs and status codes; a changed constant there
surfaces as a wrong error string far away. - Note: there is no pytest configuration section, so runs are plain. Mirror the source path into
tests/—oauthlib/oauth2/rfc6749/grant_types/x.pyis covered bytests/oauth2/rfc6749/grant_types/test_x.py. - Tests:
python -m pytest tests/oauth2 -q, or the mirrored file for the module you changed.
If it is none of these
The shape still holds: source at the top level or under src/, tests mirroring it under tests/, data
and golden files inside the test tree and never to be edited. Find the test file whose name matches your
module and run that first.