def test_read_collects_stats_only_if_flag_set(self, info, stats): p = HAProxyPlugin(Mock()) p.include_stats = False p.read() self.assertFalse(stats.called) p.include_stats = True p.read() stats.assert_called_once_with()