@@ -140,6 +140,20 @@ const PYTEST_BUILTINS: &[&str] = &[
140140 "recwarn" ,
141141 // Pytestconfig
142142 "pytestconfig" ,
143+ // pytest-django fixtures (Issue #39)
144+ // Priority 1: Core
145+ "db" ,
146+ "client" ,
147+ "rf" ,
148+ // Priority 2: Admin/User
149+ "admin_client" ,
150+ "admin_user" ,
151+ "django_user_model" ,
152+ "django_username_field" ,
153+ // Priority 3: Advanced
154+ "settings" ,
155+ "transactional_db" ,
156+ "live_server" ,
143157] ;
144158
145159/// Check if a fixture name is a pytest builtin
@@ -592,7 +606,8 @@ mod tests {
592606
593607 #[ test]
594608 fn test_transitive_dependency_resolution ( ) {
595- // Create a chain: test_foo -> db -> connection -> base
609+ // Create a chain: test_foo -> database -> connection -> base
610+ // Note: Using "database" instead of "db" since "db" is now a pytest-django builtin
596611 let discovery = DiscoveryResult {
597612 modules : vec ! [
598613 TestModule {
@@ -601,14 +616,14 @@ mod tests {
601616 fixtures: vec![
602617 make_fixture( "base" , vec![ ] ) ,
603618 make_fixture( "connection" , vec![ "base" ] ) ,
604- make_fixture( "db " , vec![ "connection" ] ) ,
619+ make_fixture( "database " , vec![ "connection" ] ) ,
605620 ] ,
606621 hooks: vec![ ] ,
607622 is_toxic: false ,
608623 } ,
609624 TestModule {
610625 path: PathBuf :: from( "test_chain.py" ) ,
611- tests: vec![ make_test( "test_foo" , vec![ "db " ] ) ] ,
626+ tests: vec![ make_test( "test_foo" , vec![ "database " ] ) ] ,
612627 fixtures: vec![ ] ,
613628 hooks: vec![ ] ,
614629 is_toxic: false ,
@@ -628,7 +643,7 @@ mod tests {
628643 assert_eq ! ( test. fixtures. len( ) , 3 ) ;
629644 assert_eq ! ( test. fixtures[ 0 ] . name, "base" ) ;
630645 assert_eq ! ( test. fixtures[ 1 ] . name, "connection" ) ;
631- assert_eq ! ( test. fixtures[ 2 ] . name, "db " ) ;
646+ assert_eq ! ( test. fixtures[ 2 ] . name, "database " ) ;
632647 }
633648
634649 // =========================================================================
@@ -655,8 +670,8 @@ mod tests {
655670 #[ test]
656671 fn test_is_builtin_fixture_negative ( ) {
657672 assert ! ( !is_builtin_fixture( "my_custom_fixture" ) ) ;
658- assert ! ( !is_builtin_fixture( "db" ) ) ;
659673 assert ! ( !is_builtin_fixture( "mock_page" ) ) ;
674+ assert ! ( !is_builtin_fixture( "unknown_fixture" ) ) ;
660675 }
661676
662677 #[ test]
@@ -693,18 +708,19 @@ mod tests {
693708 #[ test]
694709 fn test_mixed_builtin_and_user_fixtures ( ) {
695710 // Test depends on both builtin and user-defined fixture
711+ // Note: Using "database" instead of "db" since "db" is now a pytest-django builtin
696712 let discovery = DiscoveryResult {
697713 modules : vec ! [
698714 TestModule {
699715 path: PathBuf :: from( "conftest.py" ) ,
700716 tests: vec![ ] ,
701- fixtures: vec![ make_fixture( "db " , vec![ ] ) ] ,
717+ fixtures: vec![ make_fixture( "database " , vec![ ] ) ] ,
702718 hooks: vec![ ] ,
703719 is_toxic: false ,
704720 } ,
705721 TestModule {
706722 path: PathBuf :: from( "test_mixed.py" ) ,
707- tests: vec![ make_test( "test_db_with_tmp" , vec![ "db " , "tmp_path" ] ) ] ,
723+ tests: vec![ make_test( "test_db_with_tmp" , vec![ "database " , "tmp_path" ] ) ] ,
708724 fixtures: vec![ ] ,
709725 hooks: vec![ ] ,
710726 is_toxic: false ,
@@ -720,7 +736,7 @@ mod tests {
720736 assert_eq ! ( runnable. len( ) , 1 ) ;
721737 // Only user fixture should be in resolved list (builtin is skipped)
722738 assert_eq ! ( runnable[ 0 ] . fixtures. len( ) , 1 ) ;
723- assert_eq ! ( runnable[ 0 ] . fixtures[ 0 ] . name, "db " ) ;
739+ assert_eq ! ( runnable[ 0 ] . fixtures[ 0 ] . name, "database " ) ;
724740 }
725741
726742 // =========================================================================
@@ -807,34 +823,35 @@ mod tests {
807823 #[ test]
808824 fn test_nested_conftest_override ( ) {
809825 // Inner conftest.py should override fixtures with same name from outer conftest.py
810- let mut outer_db = make_fixture ( "db" , vec ! [ "connection" ] ) ;
811- let inner_db = make_fixture ( "db" , vec ! [ ] ) ; // Inner fixture has no deps
826+ // Note: Using "database" instead of "db" since "db" is now a pytest-django builtin
827+ let mut outer_database = make_fixture ( "database" , vec ! [ "connection" ] ) ;
828+ let inner_database = make_fixture ( "database" , vec ! [ ] ) ; // Inner fixture has no deps
812829
813830 // Need to distinguish them
814- outer_db . scope = FixtureScope :: Session ; // Outer has session scope
831+ outer_database . scope = FixtureScope :: Session ; // Outer has session scope
815832
816833 let discovery = DiscoveryResult {
817834 modules : vec ! [
818- // Outer conftest.py with db fixture (session scope, has deps)
835+ // Outer conftest.py with database fixture (session scope, has deps)
819836 TestModule {
820837 path: PathBuf :: from( "conftest.py" ) ,
821838 tests: vec![ ] ,
822- fixtures: vec![ outer_db , make_fixture( "connection" , vec![ ] ) ] ,
839+ fixtures: vec![ outer_database , make_fixture( "connection" , vec![ ] ) ] ,
823840 hooks: vec![ ] ,
824841 is_toxic: false ,
825842 } ,
826- // Inner conftest.py with db fixture (function scope, no deps)
843+ // Inner conftest.py with database fixture (function scope, no deps)
827844 TestModule {
828845 path: PathBuf :: from( "tests/conftest.py" ) ,
829846 tests: vec![ ] ,
830- fixtures: vec![ inner_db ] ,
847+ fixtures: vec![ inner_database ] ,
831848 hooks: vec![ ] ,
832849 is_toxic: false ,
833850 } ,
834851 // Test in inner directory should use inner fixture
835852 TestModule {
836853 path: PathBuf :: from( "tests/test_override.py" ) ,
837- tests: vec![ make_test( "test_db " , vec![ "db " ] ) ] ,
854+ tests: vec![ make_test( "test_database " , vec![ "database " ] ) ] ,
838855 fixtures: vec![ ] ,
839856 hooks: vec![ ] ,
840857 is_toxic: false ,
@@ -848,13 +865,13 @@ mod tests {
848865
849866 assert ! ( errors. is_empty( ) ) ;
850867 assert_eq ! ( runnable. len( ) , 1 ) ;
851- // Should only have 1 fixture (inner db , no transitive deps)
868+ // Should only have 1 fixture (inner database , no transitive deps)
852869 assert_eq ! (
853870 runnable[ 0 ] . fixtures. len( ) ,
854871 1 ,
855872 "Should use inner conftest fixture which has no dependencies"
856873 ) ;
857- assert_eq ! ( runnable[ 0 ] . fixtures[ 0 ] . name, "db " ) ;
874+ assert_eq ! ( runnable[ 0 ] . fixtures[ 0 ] . name, "database " ) ;
858875 // Inner fixture has function scope (default)
859876 assert_eq ! ( runnable[ 0 ] . fixtures[ 0 ] . scope, FixtureScope :: Function ) ;
860877 }
0 commit comments