FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Debian > Debian Development

 
 
LinkBack Thread Tools
 
Old 05-14-2010, 08:20 AM
Ales Kozumplik
 
Default Add doctests and integrate them into unittest system Add test for isEfiPartition Add dummy implementation for some file methods Add Mock class

On 05/14/2010 10:06 AM, Martin Sivak wrote:

---
anaconda | 4 +-
tests/__init__.py | 14 ++-
tests/doctests/bootloader.txt | 57 +++++++++
tests/doctests/language.txt | 3 +
tests/doctests/options.txt | 6 +
tests/doctests/run_tests.py | 65 ++++++++++
tests/doctests/selftest.txt | 42 +++++++
tests/mock/__init__.py | 2 +
tests/mock/disk.py | 68 ++++++++++
tests/mock/mock.py | 271 +++++++++++++++++++++++++++++++++++++++++
10 files changed, 524 insertions(+), 8 deletions(-)
create mode 100644 tests/doctests/__init__.py
create mode 100644 tests/doctests/bootloader.txt
create mode 100644 tests/doctests/language.txt
create mode 100644 tests/doctests/options.txt
create mode 100755 tests/doctests/run_tests.py
create mode 100644 tests/doctests/selftest.txt
create mode 100644 tests/mock/__init__.py
create mode 100644 tests/mock/disk.py
create mode 100644 tests/mock/mock.py



Hi Martin,

I think everyone is happy to see new unit tests, so a huge ack in
general, with some concrete objections inlined.



diff --git a/tests/doctests/selftest.txt b/tests/doctests/selftest.txt
new file mode 100644
index 0000000..28e9e07
--- /dev/null
+++ b/tests/doctests/selftest.txt
@@ -0,0 +1,42 @@
+>>> from tests.dummies import O, InitTest
+>>> 1+1
+2
+>>> 2*9
+18
+>>> raise Exception("lala")
+Traceback (most recent call last):
+...
+Exception: lala
+>>> Test = InitTest()
+>>> f = file("/tmp/test.txt", "r")
+Traceback (most recent call last):
+...
+IOError: [Errno 2] No such file or directory: '/tmp/test.txt'
+>>> f = open("/tmp/test.txt", "w")
+>>> f.write("test")
+>>> Test.fs["/tmp/test.txt"]
+'
+>>> f.flush()
+>>> Test.fs["/tmp/test.txt"]
+'test'
+>>> import os
+>>> f.seek(-2, os.SEEK_CUR)
+>>> f.write("02")
+>>> f.close()
+>>> __testenv__.fs["/tmp/test.txt"]
+'te02'
+>>> os.path.exists("/tmp/test.txt")
+True
+>>> os.path.exists("/etc/passwd")
+False
+>>> os.access('/tmp/test.txt', os.R_OK)
+True
+>>> os.remove("/tmp/test.txt")
+>>> os.path.exists("/tmp/test.txt")
+False
+>>> os.remove("/tmp/test.txt")
+Traceback (most recent call last):
+...
+OSError: [Errno 2] No such file or directory: '/tmp/test.txt'
+>>> os.access('/tmp/test.txt', os.R_OK)
+False


We talked about this questionable practice of testing mocks (which are
part of tests already).



diff --git a/tests/mock/__init__.py b/tests/mock/__init__.py
new file mode 100644
index 0000000..5e2c84d
--- /dev/null
+++ b/tests/mock/__init__.py
@@ -0,0 +1,2 @@
+from disk import *


Please mention at the top of this file what it does and why you need it.


diff --git a/tests/mock/mock.py b/tests/mock/mock.py
new file mode 100644
index 0000000..03871d6
--- /dev/null
+++ b/tests/mock/mock.py
@@ -0,0 +1,271 @@
+# mock.py
+# Test tools for mocking and patching.
+# Copyright (C) 2007-2009 Michael Foord
+# E-mail: fuzzyman AT voidspace DOT org DOT uk
+
+# mock 0.6.0
+# http://www.voidspace.org.uk/python/mock/
+
+# Released subject to the BSD License
+# Please see http://www.voidspace.org.uk/python/license.shtml
+
+# Scripts maintained at http://www.voidspace.org.uk/python/index.shtml
+# Comments, suggestions and bug reports welcome.
+


Just make sure to remove this once mock is properly packaged in fedora.

Ales

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 

Thread Tools




All times are GMT. The time now is 05:36 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org