1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
|
From: Michael Fladischer <FladischerMichael@fladi.at>
Date: Wed, 25 Nov 2020 23:11:08 +0100
Subject: Use tempfile module to create output file in tests.
---
crontab.py | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/crontab.py b/crontab.py
index ae258b9..adea392 100644
--- a/crontab.py
+++ b/crontab.py
@@ -18,6 +18,7 @@
"""
from crontab import CronTab
import sys
+import tempfile
# Create a new non-installed crontab
cron = CronTab(tab='')
@@ -68,7 +69,8 @@ output = cron.render()
cron.write()
-cron.write(filename='/tmp/output.txt')
+with tempfile.NamedTemporaryFile() as fp:
+ cron.write(filename=fp.name)
#cron.write_to_user(user=True)
|