@@ -951,7 +951,10 @@ def index():
951951
952952
953953def test_nesting_subdomains (app , client ) -> None :
954- subdomain = "api"
954+ app .subdomain_matching = True
955+ app .config ["SERVER_NAME" ] = "example.test"
956+ client .allow_subdomain_redirects = True
957+
955958 parent = flask .Blueprint ("parent" , __name__ )
956959 child = flask .Blueprint ("child" , __name__ )
957960
@@ -960,42 +963,31 @@ def index():
960963 return "child"
961964
962965 parent .register_blueprint (child )
963- app .register_blueprint (parent , subdomain = subdomain )
964-
965- client .allow_subdomain_redirects = True
966-
967- domain_name = "domain.tld"
968- app .config ["SERVER_NAME" ] = domain_name
969- response = client .get ("/child/" , base_url = "http://api." + domain_name )
966+ app .register_blueprint (parent , subdomain = "api" )
970967
968+ response = client .get ("/child/" , base_url = "http://api.example.test" )
971969 assert response .status_code == 200
972970
973971
974972def test_child_and_parent_subdomain (app , client ) -> None :
975- child_subdomain = "api"
976- parent_subdomain = "parent"
973+ app .subdomain_matching = True
974+ app .config ["SERVER_NAME" ] = "example.test"
975+ client .allow_subdomain_redirects = True
976+
977977 parent = flask .Blueprint ("parent" , __name__ )
978- child = flask .Blueprint ("child" , __name__ , subdomain = child_subdomain )
978+ child = flask .Blueprint ("child" , __name__ , subdomain = "api" )
979979
980980 @child .route ("/" )
981981 def index ():
982982 return "child"
983983
984984 parent .register_blueprint (child )
985- app .register_blueprint (parent , subdomain = parent_subdomain )
986-
987- client .allow_subdomain_redirects = True
988-
989- domain_name = "domain.tld"
990- app .config ["SERVER_NAME" ] = domain_name
991- response = client .get (
992- "/" , base_url = f"http://{ child_subdomain } .{ parent_subdomain } .{ domain_name } "
993- )
985+ app .register_blueprint (parent , subdomain = "parent" )
994986
987+ response = client .get ("/" , base_url = "http://api.parent.example.test" )
995988 assert response .status_code == 200
996989
997- response = client .get ("/" , base_url = f"http://{ parent_subdomain } .{ domain_name } " )
998-
990+ response = client .get ("/" , base_url = "http://parent.example.test" )
999991 assert response .status_code == 404
1000992
1001993
0 commit comments