ae36af
diff --git a/lib/dns/tests/dnstap_test.c b/lib/dns/tests/dnstap_test.c
ae36af
index 56e3da4..1f31542 100644
ae36af
--- a/lib/dns/tests/dnstap_test.c
ae36af
+++ b/lib/dns/tests/dnstap_test.c
ae36af
@@ -297,6 +297,9 @@ ATF_TC_BODY(totext, tc) {
ae36af
 
ae36af
 	UNUSED(tc);
ae36af
 
ae36af
+	/* make sure text conversion gets the right local time */
ae36af
+	setenv("TZ", "PST8", 1);
ae36af
+
ae36af
 	result = dns_test_begin(NULL, true);
ae36af
 	ATF_REQUIRE(result == ISC_R_SUCCESS);
ae36af
 
ae36af
@@ -306,9 +309,6 @@ ATF_TC_BODY(totext, tc) {
ae36af
 	result = isc_stdio_open(TAPTEXT, "r", &fp);
ae36af
 	ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
ae36af
 
ae36af
-	/* make sure text conversion gets the right local time */
ae36af
-	setenv("TZ", "PST8", 1);
ae36af
-
ae36af
 	while (dns_dt_getframe(handle, &data, &dsize) == ISC_R_SUCCESS) {
ae36af
 		dns_dtdata_t *dtdata = NULL;
ae36af
 		isc_buffer_t *b = NULL;