"""Test the profile listing and creation

Copyright (c) 2015 Francesco Montesano
MIT Licence
"""
import pytest

import dodocs


# fixtures
@pytest.fixture
def profile_list():
    """Execute the command profile list"""
    command_line = 'profile list'
    dodocs.main(command_line.split())


@pytest.fixture
def profile_rm():
    """Execute the command profile remove"""
    command_line = 'profile remove dodocs_pytest'
    dodocs.main(command_line.split())


@pytest.fixture
def profile_edit():
    """Execute the command profile edit"""
    command_line = 'profile edit dodocs_pytest'
    dodocs.main(command_line.split())


# profile listing
def test_list_no_exist(tmp_homedir, profile_list, caplog):
    """Test that listing without a dodocs directory fails"""
    record = caplog.records()[0]
    assert record.levelname == "CRITICAL"
    assert "No dodocs directory found" in record.message


# profile removal
def test_rm_no_exists(tmp_homedir, profile_rm, caplog):
    """Test that removing without a dodocs directory print a warning as first
    message"""
    record = caplog.records()[0]
    assert record.levelname == "WARNING"
    assert "Profile does not exist" in record.message


# profile editing
def test_edit_no_exists(tmp_homedir, profile_edit, caplog):
    """Test that removing without a dodocs directory print a warning as first
    message"""
    record = caplog.records()[0]
    assert record.levelname == "CRITICAL"
    assert "No dodocs directory found" in record.message


@pytest.mark.skipif("True")
def test_list():
    "List profiles"
    command_line = 'profile list'
    dodocs.main(command_line.split())


@pytest.mark.skipif("True")
def test_create():
    "List profiles"
    command_line = 'profile create'
    # dodocs.main(command_line.split())

@@ -662,30 +662,32 @@
 o_exist(tmp_
-homedi
+and_clea
 r, profile_l
@@ -887,32 +887,208 @@
 ecord.message%0A%0A%0A
+def test_list(create_and_clear, profile_list, caplog):%0A    %22List profiles%22%0A    print(len(caplog.records()))%0A    assert all(%5Br.levelname == %22INFO%22 for r in caplog.records()%5D)%0A%0A%0A
 # profile remova
@@ -1107,38 +1107,40 @@
 m_no_exists(tmp_
-homedi
+and_clea
 r, profile_rm, c
@@ -1420,14 +1420,16 @@
 tmp_
-homedi
+and_clea
 r, p
@@ -1681,147 +1681,8 @@
 e%0A%0A%0A
-@pytest.mark.skipif(%22True%22)%0Adef test_list():%0A    %22List profiles%22%0A    command_line = 'profile list'%0A    dodocs.main(command_line.split())%0A%0A%0A
 @pyt

Use new fixtures, test listing existing profile