# This file is part of python-markups test suite
# License: BSD
# Copyright: (C) Dmitry Shachnev, 2012

import markups.web
import os
import unittest

class WebTest(unittest.TestCase):
	def setUp(self):
		if os.path.exists('tests/data'):
			self.working_dir='tests/data'
		elif os.path.exists('data'):
			self.working_dir='data'
		else:
			raise RuntimeError('Could not find data directory!')
		self.get_file = lambda fn: os.path.join(self.working_dir, fn)

	def test_web(self):
		app_data = ('test', '1.0', 'http://example.com/')
		lib = markups.web.WebLibrary(self.working_dir, app_data)
		lib.update('page.rst')
		expected_file = open(self.get_file('page.html'))
		expected_output = expected_file.read()
		expected_file.close()
		html_file = open(self.get_file('html/page.html'))
		html_output = html_file.read()
		html_file.close()
		self.assertEqual(expected_output, html_output)
		os.remove(self.get_file('html/page.html'))
		lib.update_all()
		self.assertTrue(os.path.exists(self.get_file('html/page.html')))

	def tearDown(self):
		os.remove(self.get_file('html/page.html'))
		os.rmdir(self.get_file('html'))

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

@@ -141,16 +141,76 @@
 unittest
+%0Afrom markups.restructuredtext import ReStructuredTextMarkup
 %0A%0Aclass 
@@ -242,22 +242,40 @@
 ):%0A%09
-def setUp(self
+@classmethod%0A%09def setUpClass(cls
 ):%0A%09
@@ -303,37 +303,32 @@
 ests/data'):%0A%09%09%09
-self.
 working_dir='tes
@@ -370,21 +370,16 @@
 a'):%0A%09%09%09
-self.
 working_
@@ -455,20 +455,19 @@
 ry!')%0A%09%09
-self
+cls
 .get_fil
@@ -470,16 +470,29 @@
 _file = 
+staticmethod(
 lambda f
@@ -507,21 +507,16 @@
 th.join(
-self.
 working_
@@ -527,30 +527,9 @@
  fn)
-%0A%0A%09def test_web(self):
+)
 %0A%09%09a
@@ -579,16 +579,20 @@
 om/')%0A%09%09
+cls.
 lib = ma
@@ -612,21 +612,16 @@
 Library(
-self.
 working_
@@ -635,18 +635,129 @@
 p_data)%0A
-%09%09
+%0A%09@unittest.skipUnless(ReStructuredTextMarkup.available(), 'Docutils not available')%0A%09def test_web(self):%0A%09%09self.
 lib.upda
@@ -777,23 +777,12 @@
 )%0A%09%09
-expected_file =
+with
  ope
@@ -810,17 +810,36 @@
 .html'))
-%0A
+ as expected_file:%0A%09
 %09%09expect
@@ -877,43 +877,12 @@
 )%0A%09%09
-expected_file.close()%0A%09%09html_file =
+with
  ope
@@ -915,17 +915,32 @@
 .html'))
-%0A
+ as html_file:%0A%09
 %09%09html_o
@@ -968,28 +968,8 @@
 d()%0A
-%09%09html_file.close()%0A
 %09%09se
@@ -1060,16 +1060,21 @@
 ml'))%0A%09%09
+self.
 lib.upda
@@ -1155,28 +1155,100 @@
 )%0A%0A%09
-def tearDown(self
+@classmethod%0A%09def tearDownClass(cls):%0A%09%09if os.path.exists(cls.get_file('html/page.html')
 ):%0A
+%09
 %09%09os
@@ -1247,36 +1247,35 @@
 ):%0A%09%09%09os.remove(
-self
+cls
 .get_file('html/
@@ -1287,16 +1287,60 @@
 html'))%0A
+%09%09if os.path.exists(cls.get_file('html')):%0A%09
 %09%09os.rmd
@@ -1342,20 +1342,19 @@
 s.rmdir(
-self
+cls
 .get_fil
@@ -1365,16 +1365,119 @@
 tml'))%0A%0A
+if not hasattr(WebTest, 'assertRaisesRegex'):%0A%09WebTest.assertRaisesRegex = WebTest.assertRaisesRegexp%0A%0A
 if __nam

Refactor test_web.py