473,624 Members | 2,264 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

set and frozenset unit tests?

I have released interval-0.2.1 at
http://members.cox.net/apoco/interval/. IntervalSet and
FrozenIntervalS et objects are now (as far as I can tell) functionality
equivalent to set and frozenset objects, except they can contain
intervals as well as discrete values.

Though I have my own unit tests for verifying this claim, I'd like to
run my code through actual set and frozenset unit tests. Does any such
code exist? Is it in pure Python? If so, where can it be obtained?

Oh, and again, I'd really appreciate additional feedback on the module,
especially related to design, if you've got any. My goal for this
project is to make the classes built-in-data-type quality.

--
Jacob
Jul 21 '05 #1
5 1819
Jacob Page wrote:
I have released interval-0.2.1 at
http://members.cox.net/apoco/interval/. IntervalSet and
FrozenIntervalS et objects are now (as far as I can tell) functionality
equivalent to set and frozenset objects, except they can contain
intervals as well as discrete values.

Though I have my own unit tests for verifying this claim, I'd like to
run my code through actual set and frozenset unit tests. Does any such
code exist? Is it in pure Python? If so, where can it be obtained?

Oh, and again, I'd really appreciate additional feedback on the module,
especially related to design, if you've got any. My goal for this
project is to make the classes built-in-data-type quality.


Look at /usr/lib/python2.x/test/ (on unix platforms).

Reinhold
Jul 21 '05 #2
Reinhold Birkenfeld wrote:
Jacob Page wrote:
I'd like to
run my code through actual set and frozenset unit tests. Does any such
code exist? Is it in pure Python? If so, where can it be obtained?


Look at /usr/lib/python2.x/test/ (on unix platforms).


Thanks for pointing that to me. For some reason, the Debian package for
python 2.4 doesn't include those tests, but I acquired them from an
alternative source.

Oye, there's quite a number of set and frozenset features that aren't
well-documented that I now need to implement. What a fun chore!
Jul 21 '05 #3
Jacob Page wrote:
Oye, there's quite a number of set and frozenset features that aren't
well-documented that I now need to implement. What a fun chore!


It would be a great help if you could submit appropriate documentation
patches for the areas you don't think are well-documented:

http://sourceforge.net/tracker/?grou...70&atid=305470

STeVe
Jul 21 '05 #4
Steven Bethard wrote:
Jacob Page wrote:
Oye, there's quite a number of set and frozenset features that aren't
well-documented that I now need to implement. What a fun chore!


It would be a great help if you could submit appropriate documentation
patches for the areas you don't think are well-documented:


Hmm, after closer scrutiny, I'm not sure if the documentation really
does need modification. The largest incompatibility between IntervalSet
and set was that my code wasn't enforcing hashability, and that property
of sets actually IS documented. However, there are two minor things I
don't see documented that caught me by surprise:

* Since the <=, <, >, and >= operators raise an exception if the
right-hand operand is not a set or frozenset, it seemed reasonable to
me to assume that == and != should, too. However, the test suite for
sets expect the comparisons to be allowed; == between a set and non-set
return False, != returns True. Seems inconsistent with the rest of the
operators, but then again, the odd use of > and < for purposes other
than ordering also seems strange.

* Apparently, if fs is a frozenset instance, fs.copy() returns a
reference to fs instead of a copy of fs, and frozenset(fs) does the
same. The unit tests also ensure that subclasses of frozenset don't do
this. It makes sense that it's done that way to save on storage space,
but it's not documented that this happens.

Both issues seem to be pretty minor unless you're making functionally
equivalent classes. I'm sure neither one will confuse someone into
using them improperly, so I think it's fine to leave the docs alone.

By the way, IntervalSet and FrozenIntervalS et, when used in place of set
and frozenset, now pass most of the tests. One notable difference
between them is that whereas sets can contain any hashable object,
IntervalSet elements must be both hashable and orderable (implement
__cmp__). Thus, commands like IntervalSet([FrozenIntervalS et(...)])
fail, unlike set([frozenset(...)]).

I've also changed the methods with mixedCase capitalization to
lower_case_with _underscores, as recommended by PEP 8.

Version 0.2.2 of the module can now be downloaded from
http://members.cox.net/apoco/interval/. I'm about to freeze the
interfaces and transition the module to beta, so if you have any
interest in the project or design change ideas, please send feedback soon.
Jul 21 '05 #5
[Jacob Page]
there are two minor things I
don't see documented that caught me by surprise:

* Since the <=, <, >, and >= operators raise an exception if the
right-hand operand is not a set or frozenset, it seemed reasonable to
me to assume that == and != should, too. However, the test suite for
sets expect the comparisons to be allowed; == between a set and non-set
return False, != returns True. Seems inconsistent with the rest of the
operators, but then again, the odd use of > and < for purposes other
than ordering also seems strange.
It is consistent with the rest of Python. It turns out to be somewhat
handy to be able to run an equality test with objects of differing
types:

if x != None: ... # doesn't blow-up is x is a string or number

if 'cat' in [1, 3.1, 'hat']: ... # doesn't blow-up during eq tests

OTOH, the subset/superset tests pretty much require a set to be on both
sides. Welcome to the strange and exciting world of rich comparisons.
* Apparently, if fs is a frozenset instance, fs.copy() returns a
reference to fs instead of a copy of fs, and frozenset(fs) does the
same. The unit tests also ensure that subclasses of frozenset don't do
this. It makes sense that it's done that way to save on storage space,
but it's not documented that this happens.


It is not documented because it is not a guaranteed part of the API.
Most immutables are like this. Whether equivalent strings and numbers
share the same object id is an implementation detail.
Raymond

Jul 21 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
3680
by: Tom Verbeure | last post by:
Hello All, so I'm now convinced that unit testing is really the way to go and I want to add it to an existing project. The first thing that I find out, is that, well, it's hard work. Harder than writing the real functional code. My application manipulates graphs. I first write the skeleton in Python, then convert it to C++ for high performance (some graphs can have millions of nodes.)
2
463
by: Stefan Behnel | last post by:
Hi! frozenset() doesn't behave as the other immutable empty data types in 2.4: ..>>> '' is '' True ..>>> () is () True ..>>> frozenset() is frozenset() False
14
2737
by: | last post by:
Hi! I'm looking for unit-testing tools for .NET. Somthing like Java has --> http://www.junit.org regards, gicio
72
5226
by: Jacob | last post by:
I have compiled a set og unit testing recommendations based on my own experience on the concept. Feedback and suggestions for improvements are appreciated: http://geosoft.no/development/unittesting.html Thanks.
6
2070
by: Michael Bray | last post by:
I've just inherited a fairly large project with multiple classes. The developer also wrote a huge number of unit tests (using NUnit) to validate that the classes work correctly. However, I don't think that the class itself should include unit tests, especially since it has to reference nunit.framework in order to compile/work, and I don't want to have to distribute the nunit.framework.dll with this class. So I created a new project,...
5
6515
by: shuisheng | last post by:
Dear All, I was told that unit test is a powerful tool for progamming. If I am writing a GUI code, is it possible to still using unit test? I have a little experience in using unittest++. But I can not work out a way to use it to test GUI code. Thanks a lot!
176
8325
by: nw | last post by:
Hi, I previously asked for suggestions on teaching testing in C++. Based on some of the replies I received I decided that best way to proceed would be to teach the students how they might write their own unit test framework, and then in a lab session see if I can get them to write their own. To give them an example I've created the following UTF class (with a simple test program following). I would welcome and suggestions on how anybody...
6
5682
by: Vyacheslav Maslov | last post by:
Hi all! I have many many many python unit test, which are used for testing some remote web service. The most important issue here is logging of test execution process and result. I strongly need following: 1. start/end timestamp for each test case (most important) 2. immediate report about exceptions (stacktrace) 3. it will be nice to use logging module for output
5
2836
by: =?Utf-8?B?cmFuZHkxMjAw?= | last post by:
I'm working in Visual Studio 2005 Team Edition for Software Developers I've used the wizard under the Test menu to create a bunch of unit tests. When I click "Test -Start Selected Test Project with Debugger" the tests run. I'd really like to create a WinForm User Interface to run the Unit Tests. The idea would be to give the user a list of Unit Tests in a table, and let the user select any combination of tests they like. The user then...
0
8233
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8170
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8675
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8619
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7158
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5561
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4173
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2604
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1482
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.