@@ -97,17 +97,26 @@ def test_setter_if_session_started_but_setting_the_same_value(attribute):
97
97
],
98
98
)
99
99
def test_location_set_to_valid_no_warning (valid_location ):
100
- options = bigquery_options .BigQueryOptions ()
101
- # Ensure that no warnings are emitted.
102
- # https://docs.pytest.org/en/7.0.x/how-to/capture-warnings.html#additional-use-cases-of-warnings-in-tests
103
- with warnings .catch_warnings ():
104
- # Turn matching UnknownLocationWarning into exceptions.
105
- # https://docs.python.org/3/library/warnings.html#warning-filter
106
- warnings .simplefilter (
107
- "error" , category = bigframes .exceptions .UnknownLocationWarning
108
- )
100
+ # test setting location through constructor
101
+ def set_location_in_ctor ():
102
+ bigquery_options .BigQueryOptions (location = valid_location )
103
+
104
+ # test setting location property
105
+ def set_location_property ():
106
+ options = bigquery_options .BigQueryOptions ()
109
107
options .location = valid_location
110
108
109
+ for op in [set_location_in_ctor , set_location_property ]:
110
+ # Ensure that no warnings are emitted.
111
+ # https://docs.pytest.org/en/7.0.x/how-to/capture-warnings.html#additional-use-cases-of-warnings-in-tests
112
+ with warnings .catch_warnings ():
113
+ # Turn matching UnknownLocationWarning into exceptions.
114
+ # https://docs.python.org/3/library/warnings.html#warning-filter
115
+ warnings .simplefilter (
116
+ "error" , category = bigframes .exceptions .UnknownLocationWarning
117
+ )
118
+ op ()
119
+
111
120
112
121
@pytest .mark .parametrize (
113
122
[
@@ -126,11 +135,20 @@ def test_location_set_to_valid_no_warning(valid_location):
126
135
],
127
136
)
128
137
def test_location_set_to_invalid_warning (invalid_location , possibility ):
129
- options = bigquery_options . BigQueryOptions ()
130
- with pytest . warns (
131
- bigframes . exceptions . UnknownLocationWarning ,
132
- match = re . escape (
133
- f"The location ' { invalid_location } ' is set to an unknown value. Did you mean ' { possibility } '?"
134
- ),
135
- ):
138
+ # test setting location through constructor
139
+ def set_location_in_ctor ():
140
+ bigquery_options . BigQueryOptions ( location = invalid_location )
141
+
142
+ # test setting location property
143
+ def set_location_property ():
144
+ options = bigquery_options . BigQueryOptions ()
136
145
options .location = invalid_location
146
+
147
+ for op in [set_location_in_ctor , set_location_property ]:
148
+ with pytest .warns (
149
+ bigframes .exceptions .UnknownLocationWarning ,
150
+ match = re .escape (
151
+ f"The location '{ invalid_location } ' is set to an unknown value. Did you mean '{ possibility } '?"
152
+ ),
153
+ ):
154
+ op ()
0 commit comments