Coverage for pesummary/tests/finish_test.py: 100.0%

24 statements  

« prev     ^ index     » next       coverage.py v7.4.4, created at 2024-05-02 08:42 +0000

1# Licensed under an MIT style license -- see LICENSE.md 

2 

3import shutil 

4import os 

5import pytest 

6 

7from .base import make_argparse 

8from pesummary.core.finish import FinishingTouches 

9import tempfile 

10 

11tmpdir = tempfile.TemporaryDirectory(prefix=".", dir=".").name 

12 

13__author__ = ["Charlie Hoy <charlie.hoy@ligo.org>"] 

14 

15 

16class TestFinishingTouches(object): 

17 """Class to test pesummary.core.finish.FinishingTouches 

18 """ 

19 def setup_method(self): 

20 """Setup the pesummary.core.finish.FinishingTouches class 

21 """ 

22 if not os.path.isdir(tmpdir): 

23 os.mkdir(tmpdir) 

24 opts, inputs = make_argparse(outdir=tmpdir) 

25 self.finish = FinishingTouches(inputs) 

26 

27 def teardown_method(self): 

28 """Remove the any files generated 

29 """ 

30 if os.path.isdir(tmpdir): 

31 shutil.rmtree(tmpdir) 

32 

33 def test_default_message(self): 

34 """Test the default email message 

35 """ 

36 message = self.finish._email_message() 

37 assert message is not None 

38 

39 def test_custom_message(self): 

40 """Test a custom email message 

41 """ 

42 custom_message = "This is a test message" 

43 message = self.finish._email_message(message=custom_message) 

44 assert message == custom_message