Add further pickle protocol 2 support:
- verifies setstate is called
- if no setstate, but getstate exists, only replace instance with state if there is no newargs;
  if there is newargs, instance should not be an empty shell
- if no newargs or setstate, adds special case handling for state as dict or 2-tuple of (dict, dict) or (None, dict)
  such that those dicts are used as a source for setattr
- No tests or code added to implemet/verify __reduce__ or __reduce_ex__ support
Merge pull request #81 from marcintustin/master

Add further pickle protocol 2 support

Signed-off-by: David Aguilar <davvid@gmail.com>
tests: move stuff into the test classes

We might want to consider eliminating jsonpickle._samples (again)
if we can move everything inline instead.

Signed-off-by: David Aguilar <davvid@gmail.com>
pickler: add support for iterable __slots__

An interesting edge case in Python is:

    class ObjectWithIterableSlots(object):
         __slots__ = iter('a')
         def __init__(self, a):
             self.a = a

    print(jsonpickle.encode(ObjectWithIterableSlots('a')))

The reason this is tricky is because __slots__ is an iterator
object and is consumed the first time it is used.  The initial
consumer may be python itself when building the class object.

There's no way to reset an iterator in Python but we can at
least use dir() to find attribute names when the __slots__
iterator has already been consumed.

Fallback to using dir() if we don't find any attributes when
iterating over __slots__.

Closes #67

Reported-by: Jason R. Coombs <jaraco@jaraco.com>
Helped-by: Marcin Tustin <marcin.tustin@gmail.com>
Signed-off-by: David Aguilar <davvid@gmail.com>