Skip to content

Commit f9e00a4

Browse files
committed
chore: Use environment variable in python tests for getting current year.
1 parent d89df74 commit f9e00a4

3 files changed

Lines changed: 6 additions & 6 deletions

File tree

hermetic_build/library_generation/owlbot/synthtool/languages/java.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
JAR_DOWNLOAD_URL = "https://github.com/google/google-java-format/releases/download/google-java-format-{version}/google-java-format-{version}-all-deps.jar"
3232
DEFAULT_FORMAT_VERSION = "1.7"
33-
CURRENT_YEAR = date.today().year
33+
CURRENT_YEAR = int(os.getenv("TEST_CURRENT_YEAR", date.now().year))
3434
GOOD_LICENSE = f"""/*
3535
* Copyright {CURRENT_YEAR} Google LLC
3636
*

hermetic_build/library_generation/tests/owlbot/java_unit_tests.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ def test_deprecate_method(self):
173173
)
174174
os.chdir(cwd)
175175

176-
@mock.patch.object(java, "CURRENT_YEAR", 2025)
176+
@mock.patch.dict(os.environ, {"TEST_CURRENT_YEAR": TEST_CURRENT_YEAR})
177177
def test_fix_proto_license(self):
178178
with tempfile.TemporaryDirectory() as tempdir:
179179
cwd = os.getcwd()
@@ -190,7 +190,7 @@ def test_fix_proto_license(self):
190190
)
191191
os.chdir(cwd)
192192

193-
@mock.patch.object(java, "CURRENT_YEAR", 2025)
193+
@mock.patch.dict(os.environ, {"TEST_CURRENT_YEAR": TEST_CURRENT_YEAR})
194194
def test_fix_proto_license_idempotent(self):
195195
with tempfile.TemporaryDirectory() as tempdir:
196196
cwd = os.getcwd()
@@ -209,7 +209,7 @@ def test_fix_proto_license_idempotent(self):
209209
)
210210
os.chdir(cwd)
211211

212-
@mock.patch.object(java, "CURRENT_YEAR", 2025)
212+
@mock.patch.dict(os.environ, {"TEST_CURRENT_YEAR": TEST_CURRENT_YEAR})
213213
def test_fix_grpc_license(self):
214214
with tempfile.TemporaryDirectory() as tempdir:
215215
cwd = os.getcwd()
@@ -226,7 +226,7 @@ def test_fix_grpc_license(self):
226226
)
227227
os.chdir(cwd)
228228

229-
@mock.patch.object(java, "CURRENT_YEAR", 2025)
229+
@mock.patch.dict(os.environ, {"TEST_CURRENT_YEAR": TEST_CURRENT_YEAR})
230230
def test_fix_grpc_license_idempotent(self):
231231
with tempfile.TemporaryDirectory() as tempdir:
232232
cwd = os.getcwd()

hermetic_build/library_generation/tests/resources/goldens/owlbot-golden.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@
3333
"license-checks.xml",
3434
"renovate.json",
3535
".gitignore"
36-
])
36+
])

0 commit comments

Comments
 (0)