~mojo-maintainers/mojo/trunk

« back to all changes in this revision

Viewing changes to mojo/tests/test_container.py

  • Committer: mergebot at canonical
  • Author(s): "Barry Price"
  • Date: 2021-02-05 13:04:37 UTC
  • mfrom: (579.1.1 mojo)
  • Revision ID: mergebot@juju-139df4-prod-is-toolbox-0.canonical.com-20210205130437-z2nmmhhe0ga2yndp
Apply Makefile's blacken rules under current latest LTS (20.04)

Reviewed-on: https://code.launchpad.net/~barryprice/mojo/blacken/+merge/397569
Reviewed-by: Tom Haddon <tom.haddon@canonical.com>

Show diffs side-by-side

added added

removed removed

Lines of Context:
64
64
        self.lxd.containers.get(self.c.container_name)
65
65
 
66
66
    def test_exists(self):
67
 
        """ Tests exists(), defined() and container property.
68
 
        """
 
67
        """Tests exists(), defined() and container property."""
69
68
        self.assertIsNone(self.c.container)
70
69
        self.assertFalse(self.c.exists())
71
70
        self.assertFalse(self.c.defined)
78
77
        self.assertTrue(self.c.defined)
79
78
 
80
79
    def test_container_states(self):
81
 
        """ Tests _check_state(), running(), start(), stop() and wait()
82
 
        """
 
80
        """Tests _check_state(), running(), start(), stop() and wait()"""
83
81
        self.c.create()
84
82
        self.c.start()
85
83
 
94
92
        self.assertRaises(ContainerTimeout, self.c._wait)
95
93
 
96
94
    def test_mounts(self):
97
 
        """ Test _ensure_mount, is_setup and destroy
98
 
        """
 
95
        """Test _ensure_mount, is_setup and destroy"""
99
96
        self.c.create()
100
97
 
101
98
        self.assertFalse(self.c.is_setup())
112
109
        os.removedirs(tmpdir)
113
110
 
114
111
    def test_network(self):
115
 
        """ Test _enable_network, _disable_network and _is_network_enabled
116
 
        """
 
112
        """Test _enable_network, _disable_network and _is_network_enabled"""
117
113
        self.c.create()
118
114
 
119
115
        self.assertTrue(self.c._is_network_enabled())
125
121
        self.assertTrue(self.c._is_network_enabled())
126
122
 
127
123
    def test_in_container_ops(self):
128
 
        """ Tests run() and put()
129
 
        """
 
124
        """Tests run() and put()"""
130
125
        test_file = "/atestfile"
131
126
        self.c.create()
132
127
        devnull = open("/dev/null", "w")
137
132
        self.assertEqual(0, self.c.run("ls " + test_file, stdout=devnull, stderr=devnull))
138
133
 
139
134
    def test_run_with_env(self):
140
 
        """ Test that run() handles environment variables
141
 
        """
 
135
        """Test that run() handles environment variables"""
142
136
        self.c.create()
143
137
        stdout = io.StringIO()
144
138
        self.override_environ("TEST_VARIABLE")