diff --git a/src/_zkapauthorizer/tests/test_plugin.py b/src/_zkapauthorizer/tests/test_plugin.py
index 01b56e4b236be033d5685281dcaafc11fac878d3..27e2a5a679cdb5c4260bb9101f02ad3b616e8171 100644
--- a/src/_zkapauthorizer/tests/test_plugin.py
+++ b/src/_zkapauthorizer/tests/test_plugin.py
@@ -16,7 +16,6 @@
 Tests for the Tahoe-LAFS plugin.
 """
 
-import os.path
 from datetime import timedelta
 from functools import partial
 from io import StringIO
@@ -623,9 +622,8 @@ class LeaseMaintenanceServiceTests(TestCase):
         # and unicode in an os.path.join() call that always fails with a
         # TypeError.
         def write_private_config(name, value):
-            privname = os.path.join(config._basedir, u"private", name)
-            with open(privname, "wb") as f:
-                f.write(value)
+            privpath = FilePath(config._basedir).descendant([u"private", name])
+            privpath.setContent(value)
 
         if servers_yaml is not None:
             # Provide it a statically configured server to connect to.