from __future__ import absolute_import, print_function
import unittest
from qtpy.QtWidgets import QApplication
from addie.utilities.customtreeview import CustomizedTreeView


class CustomTreeViewTests(unittest.TestCase):
    def setUp(self):
        self.main_window = QApplication([])

    def tearDown(self):
        self.main_window.quit()

    def test_get_selected_items(self):
        """Test get_selected_items in tree of CustomizedTreeView"""
        treeview = CustomizedTreeView(None)
        items = treeview.get_selected_items()
        self.assertEqual(items, [])
        self.assertEqual(type(items), list)

from __future__ import absolute_import, print_function
import pytest
from addie.utilities.customtreeview import CustomizedTreeView


@pytest.fixture
def custom_tree_view(qtbot):
    return CustomizedTreeView(None)


def test_get_selected_items(qtbot, custom_tree_view):
    """Test get_selected_items in tree of CustomizedTreeView"""
    items = custom_tree_view.get_selected_items()
    assert items == []
    assert type(items) == list

Refactor CustomTreeView test to use pytest-qt
Refactor CustomTreeView test to use pytest-qt

  from __future__ import absolute_import, print_function
- import unittest
+ import pytest
- from qtpy.QtWidgets import QApplication
  from addie.utilities.customtreeview import CustomizedTreeView
  
  
- class CustomTreeViewTests(unittest.TestCase):
-     def setUp(self):
-         self.main_window = QApplication([])
+ @pytest.fixture
+ def custom_tree_view(qtbot):
+     return CustomizedTreeView(None)
  
-     def tearDown(self):
-         self.main_window.quit()
  
-     def test_get_selected_items(self):
+ def test_get_selected_items(qtbot, custom_tree_view):
-         """Test get_selected_items in tree of CustomizedTreeView"""
+     """Test get_selected_items in tree of CustomizedTreeView"""
-         treeview = CustomizedTreeView(None)
-         items = treeview.get_selected_items()
+     items = custom_tree_view.get_selected_items()
-         self.assertEqual(items, [])
-         self.assertEqual(type(items), list)
+     assert items == []
+     assert type(items) == list
  
Refactor CustomTreeView test to use pytest-qt
## Code Before:
from __future__ import absolute_import, print_function
import unittest
from qtpy.QtWidgets import QApplication
from addie.utilities.customtreeview import CustomizedTreeView


class CustomTreeViewTests(unittest.TestCase):
    def setUp(self):
        self.main_window = QApplication([])

    def tearDown(self):
        self.main_window.quit()

    def test_get_selected_items(self):
        """Test get_selected_items in tree of CustomizedTreeView"""
        treeview = CustomizedTreeView(None)
        items = treeview.get_selected_items()
        self.assertEqual(items, [])
        self.assertEqual(type(items), list)

## Instruction:
Refactor CustomTreeView test to use pytest-qt
## Code After:
from __future__ import absolute_import, print_function
import pytest
from addie.utilities.customtreeview import CustomizedTreeView


@pytest.fixture
def custom_tree_view(qtbot):
    return CustomizedTreeView(None)


def test_get_selected_items(qtbot, custom_tree_view):
    """Test get_selected_items in tree of CustomizedTreeView"""
    items = custom_tree_view.get_selected_items()
    assert items == []
    assert type(items) == list
