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

import re
import requests


class WonderfulBing(object):
    def __init__(self, url, redirects=True):
        self.url = url
        self.response = requests.get(url, allow_redirects=redirects)

    def test_picture_url(self):
        picture_url = re.search(
            "/az/hprichbg/rb/.+?(?=')", self.response.text).group()
        return picture_url

    def test_picture_name(self, picture_url):
        picture_name = re.search(
            "(?<=/az/hprichbg/rb/).+?(?=_)", picture_url).group()
        return picture_name

    def test_story_name(self):
        story_name = re.search(
            '((?<=id="sh_cp" title=")|\
            (?<=class="sc_light" title=")).*(?=\(\\xa9)',
            self.response.text).group()
        return story_name


def test_ZH():
    bing_ZH = WonderfulBing('http://cn.bing.com')
    picture_url = bing_ZH.test_picture_url()
    assert picture_url
    assert bing_ZH.test_picture_name(picture_url)
    assert bing_ZH.test_story_name()


def test_EN():
    bing_EN = WonderfulBing('http://www.bing.com', False)
    picture_url = bing_EN.test_picture_url()
    assert picture_url
    assert bing_EN.test_picture_name(picture_url)
    assert bing_EN.test_story_name()

@@ -61,34 +61,99 @@
 ort 
-requests%0A%0A%0Aclass W
+os%0Aimport unittest%0Afrom subprocess import Popen%0Afrom subprocess import call%0A%0Afrom w
 onderful
 Bing
@@ -152,308 +152,317 @@
 rful
-Bing(object):%0A    def __init__(self, url, redirects=True):%0A        self.url = url%0A        self.response = requests.get(url, allow_redirects=redirects)%0A%0A    def test_picture_url(self):%0A        picture_url = re.search(%0A            %22/az/hprichbg/rb/.+?(?=')%22, self.response.text).group()%0A        return 
+_bing.wonderful_bing import WonderfulBing%0A%0Acurrent_directory = os.path.abspath(os.path.dirname(__file__))%0Adirectory_with_slash = current_directory + '/'%0A%0A%0Adef test_initial():%0A    wonderful_bing = WonderfulBing(%7B'directory': directory_with_slash%7D)%0A    assert wonderful_bing.copyright%0A    assert wonderful_bing.
 pict
@@ -470,20 +470,16 @@
 re_url%0A%0A
-    
 def test
@@ -483,845 +483,591 @@
 est_
-picture_name(self, picture_url):%0A        picture_name = re.search(%0A            %22(?%3C=/az/hprichbg/rb/).+?(?=_)%22, picture_url).group()%0A        return picture_name%0A%0A    def test_story_name(self):%0A        story_name = re.search(%0A            '((?%3C=id=%22sh_cp%22 title=%22)%7C%5C%0A            (?%3C=class=%22sc_light%22 title=%22)).*(?=%5C(%5C%5Cxa9)',%0A            self.response.text).group()%0A        return story_name%0A%0A%0Adef test_ZH():%0A    bing_ZH = WonderfulBing('http://cn.
+command():%0A    help_message_status = call(%5B%0A        'python', './wonderful_bing/wonderful_bing.py', '-h'%5D)%0A    version_status = call(%5B'python', './wonderful_bing/wonderful_bing.py',%0A                            '-V'%5D)%0A    no_dir_specified_status = call(%5B%0A        'python', './wonderful_bing/wonderful_
 bing.
-com'
+py'%5D
 )%0A    
-picture_url = bing_ZH.test_picture_url()%0A    assert picture_url%0A    assert bing_ZH.test_picture_name(picture_url)%0A    assert bing_ZH.test_story_name()%0A%0A%0Adef test_EN():%0A    bing_EN = WonderfulBing('http://www.bing.com', False)%0A    picture_url = bing_EN.test_picture_url()%0A    assert picture_url%0A    assert bing_EN.test_picture_name(picture_url)%0A    assert bing_EN.test_story_name()
+dir_specified_status = call(%5B%0A        'python', './wonderful_bing/wonderful_bing.py',%0A        '-d', '%7B%7D'.format(directory_with_slash)%5D)%0A    assert not version_status%0A    assert not help_message_status%0A    assert no_dir_specified_status%0A    assert not dir_specified_status
 %0A

Rewrite tests: add test_initial(), test_command()