#!/usr/bin/env python
# -*- coding: utf-8 -*-

import os
import unittest
from subprocess import call

from wonderful_bing.wonderful_bing import WonderfulBing

class WonderfulBingTestCase(unittest.TestCase):
    def setUp(self):
        self.current_dir = os.path.abspath(os.path.dirname(__file__))
        self.current_dir_with_slash = self.current_dir + '/'
        self.not_exist_dir = '/test/'

    def tearDown(self):
        """delete the download picture"""
        for root, dirs, files in os.walk(self.current_dir_with_slash):
            for file in files:
                if file.endswith('.jpg'):
                    os.remove(file)

    def test_initial(self):
        print "\n----------test_initial begin----------"
        wonderful_bing = WonderfulBing(
            {'directory': self.current_dir_with_slash})
        assert wonderful_bing.copyright
        assert wonderful_bing.picture_url
        print "----------test_initial end----------"

    def test_get_picture_name(self):
        print "\n----------test_get_picture_name begin----------"
        wonderful_bing = WonderfulBing(
            {'directory': self.current_dir_with_slash})
        picture_name = wonderful_bing.get_picture_name()
        assert picture_name
        print "----------test_get_picture_name end----------"

    def test_common_command(self):
        print "\n----------test_common_command begin----------"
        help_message_status = call([
            'python', './wonderful_bing/wonderful_bing.py', '-h'])
        version_status = call(['python', './wonderful_bing/wonderful_bing.py',
                               '-V'])
        dir_specified_status = call([
            'python', './wonderful_bing/wonderful_bing.py',
            '-d', '{}'.format(self.current_dir_with_slash)])
        assert not version_status
        assert not help_message_status
        assert not dir_specified_status
        print "----------test_common_command end----------"

    def test_picture_has_been_downloaded(self):
        print "\n----------test_picture_has_been_downloaded begin----------"
        call(['python', './wonderful_bing/wonderful_bing.py',
              '-d', '{}'.format(self.current_dir_with_slash)])
        picture_has_been_downloaded_status = call([
            'python', './wonderful_bing/wonderful_bing.py',
            '-d', '{}'.format(self.current_dir_with_slash)])
        assert not picture_has_been_downloaded_status
        print "----------test_picture_has_been_downloaded end----------"

    def test_without_directory(self):
        print "\n----------test_without_directory begin----------"
        no_dir_specified_status = call([
            'python', './wonderful_bing/wonderful_bing.py'])
        assert no_dir_specified_status
        print "----------test_without_directory end----------"

    def test_directory_not_exist(self):
        print "\n----------test_directory_not_exist begin----------"
        dir_not_exist_status = call([
            'python', './wonderful_bing/wonderful_bing.py',
            '-d', '{}'.format(self.not_exist_dir)])
        assert dir_not_exist_status
        print "----------test_directory_not_exist end----------"


if __name__ == '__main__':
    unittest.main()

@@ -152,16 +152,17 @@
 ulBing%0A%0A
+%0A
 class Wo
@@ -671,65 +671,8 @@
 f):%0A
-        print %22%5Cn----------test_initial begin----------%22%0A
     
@@ -849,164 +849,45 @@
 url%0A
-        print %22----------test_initial end----------%22%0A%0A    def test_get_picture_name(self):%0A        print %22%5Cn----------test_get_picture_name begin----------%22
+%0A    def test_get_picture_name(self):
 %0A   
@@ -1068,169 +1068,43 @@
 ame%0A
-        print %22----------test_get_picture_name end----------%22%0A%0A    def test_common_command(self):%0A        print %22%5Cn----------test_common_command begin----------%22
+%0A    def test_common_command(self):
 %0A   
@@ -1597,193 +1597,56 @@
 tus%0A
-        print %22----------test_common_command end----------%22%0A%0A    def test_picture_has_been_downloaded(self):%0A        print %22%5Cn----------test_picture_has_been_downloaded begin----------%22
+%0A    def test_picture_has_been_downloaded(self):
 %0A   
@@ -1998,500 +1998,228 @@
 tus%0A
-        print %22----------test_picture_has_been_downloaded end----------%22%0A%0A    def test_without_directory(self):%0A        print %22%5Cn----------test_without_directory begin----------%22%0A        no_dir_specified_status = call(%5B%0A            'python', './wonderful_bing/wonderful_bing.py'%5D)%0A        assert no_dir_specified_status%0A        print %22----------test_without_directory end----------%22%0A%0A    def test_directory_not_exist(self):%0A        print %22%5Cn----------test_directory_not_exist begin----------%22
+%0A    def test_without_directory(self):%0A        no_dir_specified_status = call(%5B%0A            'python', './wonderful_bing/wonderful_bing.py'%5D)%0A        assert no_dir_specified_status%0A%0A    def test_directory_not_exist(self):
 %0A   
@@ -2405,73 +2405,8 @@
 tus%0A
-        print %22----------test_directory_not_exist end----------%22%0A
 %0A%0Aif

Remove unnecessary print info